如何用php在页面中显示不同的时区时间?
喜欢
Eastern: 02:23 AM
Central: 02:23 AM
Asia/India: 02:23 AM
Mountain: 02:23 AM
Pacific: 02:23 AM
答案 0 :(得分:9)
foreach (DateTimeZone::listIdentifiers() as $timezone)
{
$time = new DateTime('now', new DateTimeZone($timezone));
echo $timezone . ': ' . $time->format('c').'<br>';
}
答案 1 :(得分:2)
您可以这样做:
$date = new DateTime("now", new DateTimeZone('Europe/London'));
$tz = $date->getTimezone();
echo $tz->getName() . " - " . $date->format('H:m');