How can I say this Javascript in PHP:
var ts=Date.UTC(1985,1,22);
PHP's online docs are very useful: http://www.php.net/manual/en/ref.datetime.php
mktime
takes args hour
,minute
,second
,month
,day
,year
.
$ts = mktime(0, 0, 0, 1, 22, 1985);
Date.UTC
returns milliseconds whereas mktime
returns seconds, so if you still want milliseconds, multiply by 1000.
$date = new DateTime(NULL, new DateTimeZone('UTC'));
$date->setDate(1985, 1, 22);
$ts = $date->getTimestamp();
EDIT: Corrected time zone parameter.
$ts = gmmktime(0, 0, 0, 2, 22, 1985) * 1000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With