If I do
alert(new Date(1313690400000))
returns: Thu Aug 18 2011 13:00:00 GMT-0500 (CDT)
however, PHP
echo date('Y-m-d H:i:s', 1313690400000);
returns: 1951-12-14 05:50:24
If I do
alert(new Date(1313690400000))
returns: Thu Aug 18 2011 13:00:00 GMT-0500 (CDT)
however, PHP
echo date('Y-m-d H:i:s', 1313690400000);
returns: 1951-12-14 05:50:24
JavaScript uses milliseconds as a timestamp, whereas PHP uses seconds. As a result, you get very different dates, as it is off by a factor 1000.
So remove three zeroes at the PHP side:
echo date('Y-m-d H:i:s', 1313690400);
Javascript Date is milliseconds since Epoch, whereas PHP date uses unix timestamp which is in seconds.
So to get the same date in php, divide by 1000 first
PHP's date/time functions use the number of seconds since the epoch, while Javascript uses the number of milliseconds. In your php func:
echo date('Y-m-d', 1313690400000 / 1000);