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
精彩评论