Alright when I do the code:
You get the Unix t
If you don't need (millisecond) presision, then just divide & Math.floor the javascript's function. So:
time();
and
Math.floor((new Date).getTime()/1000)
should return the same value at the same time.
The javascript
getTime() ;
method returns the number of milliseconds since midnight of January 1, 1970 and the specified date.
A php equivalent is
time() * 1000; // not microtime() as I wrongly said earlier.
However they wont match as php does not support millisecond precision it seems.
What you are looking for is millisecond time in PHP. To accomplish this you need to use a combination of the microtime function and some multiplication.
microtime when passed true
as its first parameter will return the current time as the number of seconds since the Unix epoch to the nearest microsecond.
To convert the value into an integer value of the number of milliseconds since the Unix epoch you must multiply this value by 1000 and cast to an integer.
So:
$milliseconds = (int)(microtime(true) * 1000);