tags:

views:

38

answers:

1

i get a epoch time returned from a webservice wich is about 3 years off in PHP but fine in javascript and the epochconverter.com

JS:

alert('book '+ new Date(1285565357893)); // returns a time this morning 27 sep 2010, Correct!

PHP:

echo strftime('%x', 1285565357893); // returns a date in 2013, Wrong !

Timezone is set to: Europe/Amsterdam

What am i doing wrong here ?

+5  A: 

OK, some simple time basics for you.

Javascript Date class... when you pass a numeric value to the constructor, this is the number of milliseconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

PHP date is measured as the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

Convert from milliseconds to seconds in PHP by dividing by 1000.

echo strftime('%x', floor(1285565357893/1000));
Mark Baker