I'm trying to convert a Unix Timestamp to a date using php.
But I can't seem to get the Year to work. What am I doing wrong?
Unix Timestamp: 1409522400000
gmdate("d-m-Y", 1409522400000)
PHP date: 27-12-46635
Your unix timestamp is in milisecconds, php uses seconds. Remove the last three zeroes and you get:
date('d.m.Y H:i:s', 1409522400); //01.09.2014 00:00:00
Update: If you are getting the timestamp from an api, you can divide the timestamp by 1000;
$ts = 1409522400000;
date('d.m.Y H:i:s', round($ts / 1000));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments