How can I say this Javascript in PHP:
var ts=Date.UTC(1985,1,22);
Thanks in advance.
How can I say this Javascript in PHP:
var ts=Date.UTC(1985,1,22);
Thanks in advance.
$date = new DateTime(NULL, new DateTimeZone('UTC'));
$date->setDate(1985, 1, 22);
$ts = $date->getTimestamp();
EDIT: Corrected time zone parameter.
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 still want milliseconds, multiply by 1000.