getting time zone when entering state and country (time zone to use in ics file)

后端 未结 3 1688
南笙
南笙 2021-01-22 00:31

Getting time zone when giving state and country in text box

is there any way to get the time zone of that place with this two values?

the input

3条回答
  •  清歌不尽
    2021-01-22 01:22

    This is impossible, for the simple reason that quite a few states span more than one timezone. See Wikipedia's list. Outside the US it can get even more complicated; I believe there are some cities that span multiple timezones.

    You could cobble together guesses per state (e.g. by using that list), but if this is for figuring out the user's timezone, you'll probably have better luck just comparing the client clock with the server's UTC time and estimating based on country.

    edit: Note that there's no way to ask the browser for the current timezone, either, and you can't guess reliably based on the current time, because there are many timezones where it's the same time right now but where DST is different. Your best bet is to find all the possible current timezones, estimate based on the user's location (which you also have to guess!), and just ask as a last resort.

提交回复
热议问题