Field date entering 0000-00-00 00:00:00

Asked

Viewed 356 times

2

The date field of my application is entering the values 0000-00-00 00:00:00, however I am not able to find the file that makes the Insert,

The function you save to the bank is this:

$db = & JFactory::getDBO();
if ($db->connected()) {
   $data =new stdClass();
   $data->nome = $_POST['nome'];
   $data->email = $_POST['email'];
   $data->telefone = $_POST['telefone'];
   $data->cidade = $_POST['cidade'];
   $data->estado = $_POST['estado']; 
   $db->insertObject('database_orcamentos', $data);
  • Check the database to see if the date column has a default value.

  • It’s OK, with datetime null value NO!

  • Then the problem seems to be that the date is being converted wrong. In insertObject() has no clue?

  • So, just have this line even $db->insertObject('database_orcamentos', $data); .

  • What is the name of the date column?

  • the column is called created

  • 1

    after assigning the status, add this line $data->created = date('Y-m-d H:i:s');

  • Show buddy, thank you!!!

Show 3 more comments

1 answer

2


You can force a value to that date field by creating a property with the same column name.

$data->estado = $_POST['estado'];
$data->created = date('Y-m-d H:i:s');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.