Country to Timezone mapping database

2020-01-29 09:24发布

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?

标签: timezone
7条回答
时光不老,我们不散
2楼-- · 2020-01-29 10:04

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.

查看更多
够拽才男人
3楼-- · 2020-01-29 10:05

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

查看更多
放我归山
4楼-- · 2020-01-29 10:06

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

查看更多
你好瞎i
5楼-- · 2020-01-29 10:11

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 :)

查看更多
叼着烟拽天下
6楼-- · 2020-01-29 10:11

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

查看更多
我命由我不由天
7楼-- · 2020-01-29 10:17

timezonedb: https://timezonedb.com/

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

查看更多
登录 后发表回答