如何在注册表单中检测用户时区? [英] How to detect user time-zone in sign up forms?

查看:74
本文介绍了如何在注册表单中检测用户时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很难从多个选项中选择时区.我想简化此过程.我在野外看到了一些可以做出最佳猜测的表格.我大声地寻求解决方案,但没有任何运气.有人知道怎么做吗?

Time zones can be hard to select from dozens of options. I would like to make this process simpler. I saw some forms in the wild that can do the best guess. I Goggled for a solution but with out any luck. Do any one have an idea how to do it?

推荐答案

JavaScript:

var today = new Date();

alert( today.getTimezoneOffset() );

这将给出偏移量(GMT-X),而不是实际的时区名称.请记住,相同的GMT偏移量可以对应多个时区,并且还必须考虑夏令时.但是,这可能是最容易上手的地方,只是没有让用户从下拉列表中选择他们的时区.

This will give the Offset (GMT-X), but not the actual timezone name. Keep in mind same GMT offset can correspond with multiple timezones and also have to take into account Daylight savings. However, this is probably the easiest place to start, short of giving the users pick their timezone from a dropdown.

这篇关于如何在注册表单中检测用户时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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