What is the best way of getting the timezone from the city, country that user selects?

后端 未结 2 1101
再見小時候
再見小時候 2021-01-15 16:41

I looked into javascript, and thought about using the client\'s clock, but it doesn\'t seem very reliable since the client\'s clock is out of my control.

I looked ar

2条回答
  •  没有蜡笔的小新
    2021-01-15 17:08

    I think this JavaScript tool jsTimezoneDetect is what you need. It is very easy to use and it can detect a pretty big range of timezones. Besides, if you want to detect the timezone from the country and city that the user selected, I think you would need to store the whole Olson timezone database and make Ajax call to get what you need.

提交回复
热议问题