jQuery日期选择器 - 时区问题 [英] jQuery Date Picker - TimeZone Issue

查看:301
本文介绍了jQuery日期选择器 - 时区问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在我们的网站上使用jQuery日期选择器来选择预订的日期和时间。该日历当前设置为PST,并且当用户尝试从其他时区访问时,会导致错误。我们应该将服务器设置为UTC,并让应用程序根据IP地址自动选择用户的时区。我很好奇,因为我们还必须包括手动选择,因为自动选择可能会失败(即当用户通过代理工作时)。任何建议将不胜感激。

We are using a jQuery date picker on our website to select dates and times for bookings. The calendar is currently set at PST and this causes bugs when users try to access from other timezones. Should we set the server to be UTC and have the application automatically select user's timezone based on their IP Address. I was curious as whether we would also have to include manual selection as automatic selection may fail (i.e. when user works through proxy). Any advice would be greatly appreciated.

推荐答案

用户已经选择了他们的操作系统设置中的时区。 使用javascript检测此时区(不是基于IP),并将其与日期一起传递选择器值到服务器端应用程序。您可以使用Javascript或服务器端将本地时间转换为UTC时间,无论您选择哪一个。但是请保持服务器端应用程序的UTC,因为这是一个很好的做法,内部是某些语言使用的,例如Java中的 java.util.Date

The user already selects their timezone which is in their OS settings. Use javascript to detect this timezone (not based on IP), and pass it along with the date picker value to the server-side app. You can convert the local time to UTC time in Javascript or the server-side, whichever you prefer. But keep the server side app in UTC, since it's a good practice and internally that's what some languages uses, for eg., java.util.Date in Java.

这篇关于jQuery日期选择器 - 时区问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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