jQuery.datepicker.formatDate和时区偏移量 [英] jQuery.datepicker.formatDate and timezone offset

查看:86
本文介绍了jQuery.datepicker.formatDate和时区偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要处理日期,我在我的应用程序中使用jQuery UI public 方法:jQuery.datepicker.formatDate
参见params&来源: https://github.com/ jquery / jquery-ui / blob / master / ui / jquery.ui.datepicker.js

To handle dates, i'm using a jQuery UI public method in my application: jQuery.datepicker.formatDate See params & source here : https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js

但根据计算机,有时会显示错误的日期时区。

However the wrong date is displayed sometimes, according to the computer timezone.

此处演示: http://jsfiddle.net/ 7ACdB /

在Windows中使用UTC + 1(巴黎)时区,我得到:

With a UTC+1 (paris) timezone in windows, i got :

03/30/20
03/30/20

在Windows中使用UTC-6(us& canada)时区,我得到:

With a UTC-6 (us&canada) timezone in windows, i got :

03/29/20 <- meh!
03/30/20

您需要重新启动浏览器(适用于Google Chrome浏览器)当你改变操作系统时区时。

You need to restart your browser (well for google chrome at least) when you change the OS timezone.

我的问题是你想象的03/29/20日期。

My problem is the "03/29/20" date as you can imagine.

有人可以向我解释这是正常还是jquery ui问题?

Can somebody explains to me if this is normal or a jquery ui issue ?

我开始认为看到一个是正常的周一至周五2020年3月30日00:00:00 GMT + 0200(浪漫夏令时)在美国时区为03/29/20,但我不太确定。 : - /

I'm beginning to think that it is normal to see a "Mon Mar 30 2020 00:00:00 GMT+0200 (Romance Daylight Time)" as 03/29/20 in a US timezone but i'm not so sure. :-/

推荐答案

你得到的是正确的。你的例子设定了巴黎午夜的时间。巴黎的午夜是美国东部时区的之前之前的下午6点。

What you're getting is correct. Your example sets the time at midnight for Paris. Midnight in Paris is 6PM the day before in the US for the Eastern Time Zone which I am in.

第一次:GMT + 0200是巴黎

Your first time: GMT+0200 is Paris

第二次:GMT-0500是芝加哥(注意它目前是夏令时)

Your second time: GMT-0500 is Chicago (note it is currently Daylight Savings Time)

因此,当您将时区更改为美国时(使用我们的 6个时区之一) ),输出是美国在巴黎那个时间的时间。

So, when you change the time zone to US (using one of our 6 time zones), the output is the time in the US when is that time in Paris.

这是一个更新的小提琴,时间设置为巴黎上午6点: http://jsfiddle.net/jensbits/7ACdB/1/

Here is an updated fiddle with a the time set to 6 AM Paris: http://jsfiddle.net/jensbits/7ACdB/1/

这篇关于jQuery.datepicker.formatDate和时区偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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