I have a date like this: 20-03-2016 10:28:24.8402750
the field on my database is a DateTime
. When I try to insert a record with the date above, I get: 0000-00-00 00:00:00
I also tried with TimeStamp
and same problem. What am I doing wrong?
UPDATE:
this is my code for generate the date:
$now = new DateTime(null, new DateTimeZone('Europe/Rome'));
$now->getTimezone();
$result = $now->format('d-m-Y H:i:s') . substr((string)microtime(), 1, 8);
return $result;
Just change the format string d-m-Y H:i:s
to Y-m-d H:i:s
, after you code looks like:
$result = $now->format('Y-m-d H:i:s');
And also remove milliseconds not required;
You should use DateTime
value in the default format:
2016-03-20 10:28:24
After selecting TimeStamp , use default for current time stamp. It will work then