Pulling a timestamp from an XML feed with PHP but seem to be to many digits
- by Craig Ward
I am pulling a timestamp from a feed and it gives 12 digits (1269088723811). When I convert it, it comes out as
1901-12-13 20:45:52,
but if I put the timestamp into http://www.epochconverter.com/ it comes out as
Sat, 20 Mar 2010 12:38:43 GMT, which is the correct time.
epochconverter.com mentions that it maybe in milliseconds so I have amended the script to take care of it using
$mil = $timestamp;
$seconds = $mil / 1000;
$date = date('Y-m-d H:i:s', date($seconds));
but it still converts the date wrong, 1970-01-25 20:31:23.
What am I doing wrong?