从用户选择的城市,国家/地区获取时区的最佳方法是什么? [英] What is the best way of getting the timezone from the city, country that user selects?
问题描述
我研究了javascript,并考虑使用客户端的时钟,但是由于客户端的时钟不在我的控制范围之内,所以它似乎不太可靠.
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.
我环顾四周寻找Web服务,但并不幸运.
I looked around for web services but wasn't lucky.
我基本上想要根据提供的位置(城市,国家/地区)在用户的时区中显示特定时间(例如9:00:00 GMT +4).
Basically what I want is to display a specific time (e.g. 9:00:00 GMT +4) in the user's timezone, based on location provided (city, country).
谢谢
推荐答案
我认为此JavaScript工具 jsTimezoneDetect是您所需要的.它非常易于使用,并且可以检测很大范围的时区.此外,如果要从用户选择的国家和城市中检测时区,我认为您需要存储整个Olson时区数据库并进行Ajax调用以获取所需的内容.
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.
这篇关于从用户选择的城市,国家/地区获取时区的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!