Country to Timezone mapping database

亡梦爱人 提交于 2020-01-09 05:21:09

问题


I'm looking at building a form which prompts a user for their timezone. I've looked at the 'Google approach' and it seems to work pretty well. You first select a country from a drop down list and based on the selection, it populates the drop down list with the time zone options. I've search all over for a decent database with a country - timezone relationship but can't seem to find one. Does anyone know where i can find one?


回答1:


Have you tried zoneinfo? http://www.twinsun.com/tz/tz-link.htm

"The public-domain time zone database contains code and data that represent the history of local time for many representative locations around the globe. It is updated periodically to reflect changes made by political bodies to time zone boundaries, UTC offsets, and daylight-saving rules. This database (often called tz or zoneinfo) is used by several implementations, including the GNU C Library used in GNU/Linux, FreeBSD, NetBSD, OpenBSD, Cygwin, DJGPP, AIX, Mac OS X, OpenVMS, Oracle Database, Solaris, Tru64, and UnixWare."

Hope that helps :)




回答2:


The official mappings are found in the zone.tab file of the IANA time zone database.

There is also a newer version of this file, which covers cases where a time zone may be in use by more than one country. It is also in the IANA time zone database, and is called zone1970.tab.




回答3:


Using Noda Time and the .NET Framework Culture and TimeZoneInfo classes We managed to create a Json File with the Following entries which worked for us.

  • CountryName
  • 2LetterIsoCountryCode
  • 3LetterIsoCountryCode
  • IANATimezones
  • WindowsTimezones

Each Entry contains the list of available timezone for each country.

JsonFile here




回答4:


Visit http://www.iana.org/time-zones/repository/tz-link.html

Download a Data file.

Check out the files iso3166.tab and zone.tab - between them they have everything you need.




回答5:


timezonedb: https://timezonedb.com/

could also be mentioned. You can go to download page and find what format is most suitable for your project.




回答6:


If a commercial solution is acceptable, you could check out the World Time Zone Database.




回答7:


Ruby on Rails uses the following mapping for timezones: http://apidock.com/rails/TimeZone



来源:https://stackoverflow.com/questions/1234563/country-to-timezone-mapping-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!