2011-01-29 37 views

回答

2

您可以创建DateTime对象,该对象表示任何有效的ISO-3166-1时区标识符的本地时间。

$timezones = DateTimeZone::listIdentifiers(); 

foreach($timezones as $zone) { 
    $time = new DateTime("now", new DateTimeZone($zone)); 
    printf("% 35s: %s\n", $zone, $time->format('r')); 
} 

$bigAppleTime = new DateTime("now", new DateTimeZone("America/New_York")); 
echo "It is currently " . $bigAppleTime->format('r') . " in New York city"; 

您可以通过以下操作获得在每个有效标识符的列表和当前时间

相关问题