$fromTz=">America/chicago"; //Time zone for UM6
$toTz="America/Adak" ;//Time Zone for UM4
$date = new DateTime($time, new DateTimeZone($fromTz));
echo "<br>America/chicago Time ".$date->format('Y-m-d H:i:s');
$date->setTimezone(new DateTimeZone($toTz));
$time= $date->format('Y-m-d H:i:s');
echo "<br>Time For $toTz ".$time;
我已经在php中将日期和时间从onetimezone转换为另一个时区。
我想将UM6转换为UM4,UM5,UM7,UM8
但我不知道UM5,UM7和UM8的价值 像UM4 =“America / Adak”
那么UM5,UM7和UM8的价值是什么
答案 0 :(得分:0)
使用此功能,使用此功能转换时区。
function converTotimezone($time="",$toTz='',$fromTz=''){
// timezone by php friendly values
$date = new DateTime($time, new DateTimeZone($fromTz));
$date->setTimezone(new DateTimeZone($toTz));
$time= $date->format('Y-m-d H:i:s');
return $time;
}
答案 1 :(得分:0)
Use this code
$dateTime="2017-11-02T00:00:00.000Z";
date_default_timezone_set('America/chicago');
$timeZoneFrom="America/chicago";
$date = new DateTime($dateTime, new DateTimeZone($timeZoneFrom));
$time_zoneTo="America/Adak";
$date= $date->setTimezone(new DateTimeZone($time_zoneTo));
print_r($date);
or echo $date->format("Y-m-d H:i:s"); `