MySQL仅从我的getOffset()
函数的输出中扼杀了这八个时区。
时区偏移大于12小时意味着什么?您如何建议修改,以便$os
保持在+/- 12小时之间?
function getOffset() {
$os=(new \DateTime())->getOffset();
return $os >= 0?'+'.gmdate("G:i", $os):'-'.gmdate("G:i", -$os);
}
foreach(DateTimeZone::listIdentifiers() as $tz) {
date_default_timezone_set($tz);
$os=getOffset();
$hours=explode(':',$os)[0];
if($hours>12 || $hours<-12) {
echo("$tz has offset of $os.<br>");
}
}
输出:
Antarctica/McMurdo has offset of +13:00.
Pacific/Apia has offset of +14:00.
Pacific/Auckland has offset of +13:00.
Pacific/Chatham has offset of +13:45.
Pacific/Enderbury has offset of +13:00.
Pacific/Fakaofo has offset of +13:00.
Pacific/Kiritimati has offset of +14:00.
Pacific/Tongatapu has offset of +13:00.