开发者

MySQL: How to select the UTC offset and DST for all timezones?

I want a list of all timezones in the mysql timezone tables, and need to select:

1) Their current offset from GMT

2) Whether DST is used by that timezone (not whether it's currently in use, just whether DST is considered at some point in the year for that timezone)

Reason: I need to build a web form and match the users time zone information (which I can generate from javascript) to the correct time zone stored in the mysql DB. I can find UTC offset and get a DST flag from javascript fun开发者_JAVA技巧ctions.


Try this query. The offsettime is the (Offset / 60 / 60)

SELECT tzname.`Time_zone_id`,(`Offset`/60/60) AS `offsettime`,`Is_DST`,`Name`,`Transition_type_id`,`Abbreviation`
FROM `time_zone_transition_type` AS `transition`, `time_zone_name` AS `tzname`
WHERE transition.`Time_zone_id`=tzname.`Time_zone_id`
ORDER BY transition.`Offset` ASC;

The results are

501 -12.00000000    0   0   PHOT    Pacific/Enderbury
369 -12.00000000    0   0   GMT+12  Etc/GMT+12
513 -12.00000000    0   1   KWAT    Pacific/Kwajalein
483 -12.00000000    0   1   KWAT    Kwajalein
518 -11.50000000    0   1   NUT Pacific/Niue
496 -11.50000000    0   1   SAMT    Pacific/Apia
528 -11.50000000    0   1   SAMT    Pacific/Samoa
555 -11.50000000    0   1   SAMT    US/Samoa
521 -11.50000000    0   1   SAMT    Pacific/Pago_Pago
496 -11.44888889    0   0   LMT Pacific/Apia
528 -11.38000000    0   0   LMT Pacific/Samoa
555 -11.38000000    0   0   LMT US/Samoa
521 -11.38000000    0   0   LMT Pacific/Pago_Pago
518 -11.33333333    0   0   NUT Pacific/Niue
544 -11.00000000    0   3   BST US/Aleutian
163 -11.00000000    0   3   BST America/Nome
518 -11.00000000    0   2   NUT Pacific/Niue
496 -11.00000000    0   2   WST Pacific/Apia
544 -11.00000000    0   0   NST US/Aleutian
163 -11.00000000    0   0   NST America/Nome
528 -11.00000000    0   4   SST Pacific/Samoa
528 -11.00000000    0   3   BST Pacific/Samoa
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜