I have exist microsecond timestamp = 1484923604957
and I want create DateTime object or just date, for then set in db in table with column created_at - datetime
. I don't want change type field in DB. Now I convert to date like this
$seconds = $mil / 1000;
return date("Y-m-d H:i:s", $seconds);
and in DB have 2017-01-20 14:46:44
and then when get have date without microseconds
created_at = "2016-12-29 14:42:05"
I create DateTime
$dateTimeClass = date_create_from_format('Y-m-d H:i:s', $date);
return $dateTimeClass;
and in response
$dateTimeClass->getTimestamp()*1000
this is last microsecond
How to correct convert to DatTime (or date) with microseconds and back to microseconds?