9

I'm relying on Intl to determine user's time zone.

I also want to give users a way to pick their timezone. I have a list of time zones -- some subset of Olson database.

I wanna make sure Intl won't give me some weird time zone I don't have in my list.

Where does Intl API get it's time zone list? Is there a way to list all of them or does it trust the browser?

skfd
  • 2,528
  • 1
  • 19
  • 29

1 Answers1

6

According to MDN:

The only value implementations must recognize is "UTC"; the default is the runtime's default time zone. Implementations may also recognize the time zone names of the IANA time zone database, such as "Asia/Shanghai", "Asia/Kolkata", "America/New_York".

cgatian
  • 22,047
  • 9
  • 56
  • 76
  • 3
    Yes, but IANA time zone database does not have a plane csv list. There is kind of a list https://github.com/eggert/tz/blob/master/zone1970.tab , but I fear it's not full. – skfd Jul 10 '15 at 21:14
  • What about writing a simple JavaScript program that compares your DB list to what the browser supports? – cgatian Jul 12 '15 at 19:12
  • Different browsers implement different versions of the IANA db, so that's another complication... I'll post back here if I find a way to pin a specific version. – Julian K Apr 23 '21 at 17:34