Date / Time: April / 08/2014 12:17:42 pm UTC
Java Timestamp: 1396959462222
PHP Timestamp: 1396959462
Dividing by 1000 does not give the correct answer, because it will give a double or floating value, i.e. 1396959462.222 what we do not want. We need an integer, for example 1396959462. Thus, the correct way to convert a Java timestamp to a PHP timestamp can be used using the intval () method:
$php_timestamp = intval($java_timestamp/1000);
In a real example, in one of my Android apps, where I send the Java timestamp to a PHP server, I do this as mentioned above. In addition, for good security practice, I add preg_replace () to make sure that someone has added the hack code in this field, it is deleted:
$php_timestamp = intval(preg_replace('/[^0-9]/', '', $java_timestamp)/1000);
source share