If i do
alert(new Date(1313690400000))
returns: Thu Aug 18 2011 13:00:00 GMT-0500 (CDT)
Thu Aug 18 2011 13:00:00 GMT-0500 (CDT)
however php
echo date('Ymd H:i:s', 1313690400000);
returns: 1951-12-14 05:50:24
1951-12-14 05:50:24
JavaScript uses milliseconds as a timestamp, while PHP uses seconds. As a result, you get different dates, since it is disabled 1000 times.
So, remove the three zeros from the PHP side:
echo date('Ymd H:i:s', 1313690400);
PHP's date and time functions use the number of seconds since an era, while Javascript uses the number of milliseconds. In your php func:
echo date('Ym-d', 1313690400000 / 1000);
Javascript Date is the milliseconds since the Epoch era, while the PHP date uses the unix timestamp, which is in seconds.
So, to get the same date in php, divide by 1000 first
Source: https://habr.com/ru/post/895367/More articles:Is it possible to convert PDF to a vector image format that can be printed with .NET? - c #Which regex expression will check GPS values? - phpGetting all leaves from an expression - wolfram-mathematicaCommon with ArrayAdapters - javaWhat is wrong with this PHP script to send mail using Pear Mail? - phpWhat is the difference between `>>> some_object` and` >>> print some_object` in the Python interpreter? - pythonWhy do some builds of a C ++ project show 00:00:00 elapsed time and details of the output window are not displayed? - visual-studio-2010warning: variable but not used [-Wunused-but-set-variable] - cCode Modulation Testing - c #Preventive Processing Using Wunused-but-set-variable - cAll Articles