0
Date time zone: Asia/Kolkata.
Time Stamp: 1448620722807.

Below scripts have been executed on the same system.

Java Code

System.out.println(new Date(1448620722807L)); //Fri Nov 27 10:38:42 GMT 2015

JavaScript Code

console.log(new Date(1448620722807)); //Fri Nov 27 2015 16:08:42 GMT+0530 (India Standard Time)

PHP Code:

//date_default_timezone_set("Asia/Calcutta");
date_default_timezone_set("Asia/Kolkata");
echo date_default_timezone_get(). '<br/>'; // Asia/Kolkata
echo date('d-m-Y h:i:s:A',1448620722807); // 22-07-2008 09:57:35:PM

Java and JavaScript gives the expected results. Am I missing something for PHP?

0

1 Answer 1

5

Javascript (and apparently Java as well, I don't know) handle timestamps as milliseconds, while PHP uses seconds. The correct value for PHP is 1448620722807 / 1000 for the same timestamp.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.