Pulling a timestamp from an XML feed with PHP but seem to be to many digits

Posted by Craig Ward on Stack Overflow See other posts from Stack Overflow or by Craig Ward
Published on 2010-03-21T12:56:03Z Indexed on 2010/03/21 13:01 UTC
Read the original article Hit count: 375

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about epoch

Related posts about php