如何在此代码上以秒为单位输出时区。
$tz = 'Asia/Manila';
$timestamp = time();
$dt = new DateTime("now", new DateTimeZone($tz)); //first argument "must" be a string
$dt->setTimestamp($timestamp); //adjust the object to correct timestamp
$Manila_Time_Date = $dt->format('F j, Y, g:i a');
$ Manila_Time_Date = 2018年9月4日,上午6:07
我如何做:
$ Manila_Time_Code = 1536012420(这是马尼拉时区)
答案 0 :(得分:0)
使用strtotime():
$tz = 'Asia/Manila';
$dt = new DateTime("now", new DateTimeZone($tz));
$Manila_Time_Date = strtotime($dt->format('Y-m-d H:i:s')); // <-
echo $Manila_Time_Date; // int(1536059258)
echo "<br>";
echo var_dump(time); //int(1536030458)