Convert JS timestamp to PHP

0

I would like to know how to convert this JS code to PHP:

A = new Date(2020,1,1,0,0,0).getTime();

Although the result will always "be":

1580522400000

I'm doing this:

$d = DateTime::createFromFormat('Y-n-j', '2020-2-1');
echo $d->getTimestamp();

1580580050

But the result is not beating. Well, there are the seconds I think. How to return 1580522400000 result with PHP?

    
asked by anonymous 26.04.2015 / 20:13

1 answer

2

JavaScript generates the value in milliseconds, and PHP, in seconds. To be able to compare them, multiply the PHP value by 1000, or divide the JS by 1000 and get the whole part.

    
26.04.2015 / 21:06