Inserting dates in php with PDO

0

I'm having trouble inserting a date into the database with PDO. I have a mirror class on my table in the bank:

class PaginaEntity {
private $id;
private $data;

public function __construct(){
    $this->data = date('d-m-y h:i:s A');
//gets and sethers

The class to insert:

class PaginaDao {
    public function inserirPagina(PaginaEntity $paginaEntity) {
        $conexao = new PDOUtil();
        $insert = $conexao->getStance()->prepare("INSERT INTO tabela_teste(data) VALUES(:data)");
        $insert->bindValue(":data", $paginaEntity->getData());
        $insert->execute();
    }
}

And I have the test form:

include_once '../entity/PaginaEntity.php';
include_once '../dao/PaginaDao.php';
include_once '../configs/PDOUtil.php';

if(isset($_GET["acao"])) {
    $id = $_POST["id"];
    $pagina = new PaginaEntity();    
    $daoPagina = new PaginaDao();
    $daoPagina->inserirPagina($pagina);
}
?>

<form method="post" action="testeInsercaoPagina.php?acao=ok">
    <label for="id">id da categoria</label>
    <input type="text" name="id"> <br/><br/> 
    <button type="submit">Gravar</button>    
</form>

What happens is the following error:

    
asked by anonymous 19.04.2015 / 04:25

1 answer

0

As people passed me in the comments I solved the error as follows, I got the php.ini path in the terminal php --ini soon after I added the following date.timezone = 'America/Sao_Paulo'p to configure the same, then in my database that had a varchar as value to receive a given and I changed it to timestamp as @rray had spoken.

Thank you all.

    
19.04.2015 / 05:57