jQuery UI日期选择器和时区 [英] jQuery UI Datepicker and Timezones

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

问题描述

我使用日期选择器在我的网站上整理请求的交货日期.格林尼治标准时间下午3点之前可以提供当天送达服务,因此我运行了一个脚本,以便在该日的1天之前将日历的当前选择移到第一天. 3pm是在服务器而非客户端计算机上生成的,以确保正确的时间.

我想克服这个问题: 随着日期的自然变化,澳大利亚客户会提前1天前进(他们提前11小时),这意味着他们错失了大约3个小时的当天发货时间-但我可以接受.但是,当我的脚本在英国时间下午3点开始播放时,又在第二天被推了.

示例: 1月26日下午3:15在英国,向英国用户显示的当前日期是1月27日(很酷),但是我们的Auzzie用户现在看到的是1月28日(很酷).

有没有一种方法可以将日期选择器本地化为GMT,而无需在客户端PC上运行时钟时间.

这也影响到我们在北美的访问量-但这不是一个大问题-解决一个问题应解决其余问题.

解决方案

您可以对客户端的IP地址进行地理定位,并相应地确定时区,并在您的网站上调整zime(day).
使用Javascript:请参见 Google API ClientLocation

修改,请稍候.实际上,直接使用Javascript获取日期会更容易.有什么反对的话?

  var currentDate = new Date()
  var day = currentDate.getDate()
  var month = currentDate.getMonth()
  var year = currentDate.getFullYear()
  document.write("<b>" + day + "/" + month + "/" + year + "</b>")

显然我还没睡着;)

I use the datepicker to gererate a requested delivery date on my site. Same day delivery is available until 3pm GMT, so I run a script to move the calendars current selection on by 1 day at that time. The 3pm is generated on the server and not the client machine to ensure the correct time.

I would like to overcome this problem: Australian customers moves forward by 1 day as the date there changes naturally (they are 11 hours ahead), this means they miss out on approx 3 hours of same day delivery - but I can live with that. However, when my script kicks in at 3pm UK time they get nudged on another day.

Example: Its 3:15pm in the UK on January 26th, current date showing to UK users is now January 27th (cool), but our Auzzie users are now seeing January 28th (not cool).

Is there a way to localise the datepicker to GMT without running the clock time on the client pc.

This also affects our North American traffic - but isn't such a big issue - fixing one problem should fix the rest.

解决方案

You could geo-locate the IP address of your client and figure out the time zone accordingly and adjust the zime(day) on your site.
using Javascript: see Google API ClientLocation

edit wait. It actually would be easier to get the date directly using Javascript. What speaks against it?

  var currentDate = new Date()
  var day = currentDate.getDate()
  var month = currentDate.getMonth()
  var year = currentDate.getFullYear()
  document.write("<b>" + day + "/" + month + "/" + year + "</b>")

Apparently I'm still half asleep ;)

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

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