我有UTC时间戳,想要显示不同的时区.
也许一个例子可以澄清我想要做的事情:
给定时间戳1259431620000应显示这些时间:
Atlanta 13:07
San Francisco 10:07
London 17:07
Sydney 04:07
城市可能会改变,但我想你得到了我想要的东西.
是否有javascript库或常见的解决方案来处理夏令时?
我准备好了所有时区的清单.
由于夏令时是一个容易和常见的问题,我认为可能有一个库或脚本处理它们.
以防您在时区表中感兴趣:
* GMT -11:00
o Apia
o Midway
o Niue
o Pago Pago
* GMT -10:00
o Fakaofo
o Hawaii Time
o Johnston
o Rarotonga
o Tahiti
* GMT -09:00
o (GMT-09:30) Marquesas
o Alaska Time
o Gambier
* GMT -08:00
o Pacific Time
o Pacific Time - Tijuana
o Pacific Time - Vancouver
o Pacific Time - Whitehorse
o Pitcairn
* GMT -07:00
o Mountain Time - Dawson Creek
o Mountain Time (America/Denver)
o Mountain Time - Edmonton
o Mountain Time - Hermosillo
o Mountain Time - Chihuahua, Mazatlan
o Mountain Time - Arizona
o Mountain Time - Yellowknife
* GMT -06:00
o Belize
o Central Time
o Costa Rica
o El Salvador
o Guatemala
o Managua
o Central Time - Mexico City
o Central Time - Regina
o Central Time (America/Tegucigalpa)
o Central Time - Winnipeg
o Easter Island
o Galapagos
* GMT -05:00
o Bogota
o Cayman
o Grand Turk
o Guayaquil
o Havana
o Eastern Time - Iqaluit
o Jamaica
o Lima
o Eastern Time - Montreal
o Nassau
o Eastern Time
o Panama
o Port-au-Prince
o Eastern Time - Toronto
* GMT -04:00
o (GMT-04:30) Caracas
o Anguilla
o Antigua
o Aruba
o Asuncion
o Barbados
o Boa Vista
o Campo Grande
o Cuiaba
o Curacao
o Dominica
o Grenada
o Guadeloupe
o Guyana
o Atlantic Time - Halifax
o La Paz
o Manaus
o Martinique
o Montserrat
o Port of Spain
o Porto Velho
o Puerto Rico
o Rio Branco
o Santiago
o Santo Domingo
o St. Kitts
o St. Lucia
o St. Thomas
o St. Vincent
o Thule
o Tortola
o Palmer
o Bermuda
o Stanley
* GMT -03:00
o Newfoundland Time - St. Johns
o Araguaina
o Buenos Aires
o Salvador
o Belem
o Cayenne
o Fortaleza
o Godthab
o Maceio
o Miquelon
o Montevideo
o Paramaribo
o Recife
o Sao Paulo
o Rothera
* GMT -02:00
o Noronha
o South Georgia
* GMT -01:00
o Scoresbysund
o Azores
o Cape Verde
o Abidjan
* GMT 00:00
o Accra
o Bamako
o Banjul
o Bissau
o Casablanca
o Conakry
o Dakar
o El Aaiun
o Freetown
o Lome
o Monrovia
o Nouakchott
o Ouagadougou
o Sao Tome
o Danmarkshavn
o Canary Islands
o Faeroe
o Reykjavik
o St Helena
o GMT (no daylight saving)
o Dublin
o Lisbon
o London
* GMT +01:00
o Algiers
o Bangui
o Brazzaville
o Ceuta
o Douala
o Kinshasa
o Lagos
o Libreville
o Luanda
o Malabo
o Ndjamena
o Niamey
o Porto-Novo
o Tunis
o Windhoek
o Amsterdam
o Andorra
o Central European Time
o Berlin
o Brussels
o Budapest
o Copenhagen
o Gibraltar
o Luxembourg
o Madrid
o Malta
o Monaco
o Oslo
o Paris
o Rome
o Stockholm
o Tirane
o Vaduz
o Vienna
o Warsaw
o Zurich
* GMT +02:00
o Blantyre
o Bujumbura
o Cairo
o Gaborone
o Harare
o Johannesburg
o Kigali
o Lubumbashi
o Lusaka
o Maputo
o Maseru
o Mbabane
o Tripoli
o Amman
o Beirut
o Damascus
o Gaza
o Jerusalem
o Nicosia
o Athens
o Bucharest
o Chisinau
o Helsinki
o Istanbul
o Moscow-01 - Kaliningrad
o Kiev
o Minsk
o Riga
o Sofia
o Tallinn
o Vilnius
* GMT +03:00
o Addis Ababa
o Asmera
o Dar es Salaam
o Djibouti
o Kampala
o Khartoum
o Mogadishu
o Nairobi
o Syowa
o Aden
o Baghdad
o Bahrain
o Kuwait
o Qatar
o Riyadh
o Moscow+00
o Antananarivo
o Comoro
o Mayotte
o (GMT+03:30) Tehran
* GMT +04:00
o Baku
o Dubai
o Muscat
o Tbilisi
o Yerevan
o Moscow+01 - Samara
o Mahe
o Mauritius
o Reunion
o (GMT+04:30) Kabul
* GMT +05:00
o Aqtau
o Aqtobe
o Ashgabat
o Dushanbe
o Karachi
o Tashkent
o Moscow+02 - Yekaterinburg
o Kerguelen
o Maldives
o (GMT+05:30) India Standard Time
o (GMT+05:30) Colombo
o (GMT+05:45) Katmandu
* GMT +06:00
o Mawson
o Vostok
o Almaty
o Bishkek
o Dhaka
o Moscow+03 - Omsk, Novosibirsk
o Thimphu
o Chagos
o (GMT+06:30) Rangoon
o (GMT+06:30) Cocos
* GMT +07:00
o Davis
o Bangkok
o Hovd
o Jakarta
o Moscow+04 - Krasnoyarsk
o Phnom Penh
o Hanoi
o Vientiane
o Christmas
* GMT +08:00
o Casey
o Brunei
o Choibalsan
o *
o Moscow+05 - Irkutsk
o Kuala Lumpur
o Macau
o Makassar
o Manila
o China Time - Beijing
o Singapore
o Taipei
o Ulaanbaatar
o Western Time - Perth
* GMT +09:00
o Dili
o Jayapura
o Pyongyang
o Seoul
o Tokyo
o Moscow+06 - Yakutsk
o Palau
o (GMT+09:30) Central Time - Adelaide
o (GMT+09:30) Central Time - Darwin
* GMT +10:00
o Dumont D'Urville
o Moscow+07 - Yuzhno-Sakhalinsk
o Eastern Time - Brisbane
o Eastern Time - Hobart
o Eastern Time - Melbourne, Sydney
o Guam
o Port Moresby
o Saipan
o Truk
* GMT +11:00
o Moscow+08 - Magadan
o Efate
o Guadalcanal
o Kosrae
o Noumea
o Ponape
o (GMT+11:30) Norfolk
* GMT +12:00
o Moscow+09 - Petropavlovsk-Kamchatskiy
o Auckland
o Fiji
o Funafuti
o Kwajalein
o Majuro
o Nauru
o Tarawa
o Wake
o Wallis
* GMT +13:00
o Enderbury
o Tongatapu
o Kiritimati
提前致谢
解决方法:
时区信息的综合来源是Olson list.它在UNIX世界中被广泛使用,并且也可以在例如UNIX中使用. Python的形式为pytz.似乎有人创建了some code,它也可以在JavaScript中使用,如an older SO question所述.
这似乎正是你正在寻找的;)