Reputation: 14897
Using Javascript, is it possible to get a client's Time Zone ID that maps to the Time zone IDs (or Time zone name) in this list?
Upvotes: 0
Views: 288
Reputation: 1500903
The browser itself is unlikely to know about that list in general, as they're Windows-specific IDs. You may be able to adapt existing time zone detection Javascript code to use the Windows time zones itself, but it's likely to be some work.
I'm unaware of anything built into standard Javascript which will give any sort of time zone ID, but I know there are some detection packages available which probe the UTC offset at various points in time and deduce the time zone from that. I haven't used any of them personally, so you'd need to test it yourself. (I have no particular recommendations.) Such packages are likely to give you an Olson/TZDB/zoneinfo/IANA time zone ID; you could use my Noda Time project to then use that time zone, or convert it to the closest Windows time zone.
Note that any such detection may well be error-prone due to differences between the browser's time zone database and anything on the server side; you may well wish to prompt the user for confirmation, using the detection as input to suggest the most likely options.
Upvotes: 1