basically im trying to get php equivalent time()in javascript
here is the code:
var jstamp = Math.round(new Date().getTime() / 1000) ;
var pstamp = <?php echo time(); ?>;
console.log( 'jstamp is : '+ jstamp);
console.log( 'pstamp is : '+ pstamp);
here is the result:
jstamp is : 13939 45587
pstamp is : 13939 33954
they differ from each other in the last 5 digits
echo date_default_timezone_get();
echo date('Y-m-d H:i:s');
result:
UTC2014-03-04 11:57:13
Server time seems wrong but shouldn't be wrong for php and js? that still I should not get the same result in both of them?
source
share