从用户选择的城市,国家/地区获取时区的最佳方法是什么? [英] What is the best way of getting the timezone from the city, country that user selects?

查看:75
本文介绍了从用户选择的城市,国家/地区获取时区的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆