生成和排序时区区域

时间:2011-04-22 07:59:56

标签: php timezone datetimeoffset

如何根据http://php.net/manual/en/timezones.php中的区域列表输出时区偏移?

理想情况下,我希望它在UTC-12:00到UTC + 12:00格式中“安排”。

所以,

America/New_York should generate UTC-4:00
UTC should be UTC
Asia/Damascus should be UTC+3:00
etc

它的输出当然应该匹配http://en.wikipedia.org/wiki/List_of_tz_database_time_zones ...


Q2:是否有一些标准化的订单可以显示此列表?当然,GMT-11到GMT + 12,但由于许多地区重叠,我该如何展示?所有这些地区都将成为一个下拉列表的一部分:

(GMT-11:00) Pacific/Niue
(GMT-11:00) Pacific/Apia
(GMT-11:00) Pacific/Midway
(GMT-11:00) Pacific/Pago_Pago
(GMT-10:00) Pacific/Fakaofo
(GMT-10:00) Pacific/Rarotonga
(GMT-10:00) Pacific/Johnston
(GMT-10:00) Pacific/Tahiti
(GMT-10:00) Pacific/Honolulu
   [but what order should the above be in?]

2 个答案:

答案 0 :(得分:1)

date_default_timezone_set('time_zone_string')

查阅手册以查看可用时区

编辑:

我第二次看到我没有清楚地回答你的问题,你可以使用这个功能:

DateTimeZone::getOffset();

更多详细信息here

答案 1 :(得分:0)

只需按偏移排序,然后按字母顺序排列。本来希望采用更“地理”的方法 - 但没有找到任何指示如何做的事情。