Firefox 不适用于 "Wed. October 28, 2015" 格式的 new Date()
Firefox doesn't work with new Date() with format like "Wed. October 28, 2015"
这就是我的。
date = testInfoSelect.testDate;
console.log(date);
date = new Date(date);
console.log(date);
date = $.datepicker.formatDate('mm/dd/yy', date);
console.log(date);
这是 FF 中的控制台输出。
"Wed. February 24, 2016"
Invalid Date
"NaN/NaN/NaN"
这是 Chrome 中的控制台输出。
Wed. February 24, 2016
Wed Feb 24 2016 00:00:00 GMT-0500 (Eastern Standard Time)
02/24/2016
对于我的申请,我无法更改日期格式,即 testInfoSelect.testDate,在本例中为 "Wed. February 24, 2016"。
我做了什么:
dateString String value representing a date. The string should be in a
format recognized by the Date.parse() method (IETF-compliant RFC 2822
timestamps and also a version of ISO8601).
MDN文档中最相似的日期格式是这样的:
Date.parse('Wed, 09 Aug 1995 00:00:00 GMT');
在不改变"Wed. February 24, 2016"
格式的情况下,如何在FF中得到正确的结果
谢谢
如@adeno 所述,黑客可以:
new Date("Wed. February 24, 2016".replace('.', ''));
或
new Date("Wed. February 24, 2016".replace('.', ','));
你的情况:
new Date(date.replace('.', ''));
要获取 GMT 时间,您可以执行以下操作:
> new Date(date.replace('.', '') + " GMT");
< Date 2016-02-24T00:00:00.000Z
FF、Chrome 和 Opera 的结果:
火狐:
▶ new Date("Wed. February 24, 2016".replace('.', '') + " GMT");
⯇ Date 2016-02-24T00:00:00.000Z
Chrome:
> new Date("Wed. February 24, 2016".replace('.', '') + " GMT");
<- Wed Feb 24 2016 01:00:00 GMT+0100 (CET)
歌剧:
>>> new Date("Wed. February 24, 2016".replace('.', '') + " GMT");
[+] Wed Feb 24 2016 01:00:00 GMT+0100
这就是我的。
date = testInfoSelect.testDate;
console.log(date);
date = new Date(date);
console.log(date);
date = $.datepicker.formatDate('mm/dd/yy', date);
console.log(date);
这是 FF 中的控制台输出。
"Wed. February 24, 2016"
Invalid Date
"NaN/NaN/NaN"
这是 Chrome 中的控制台输出。
Wed. February 24, 2016
Wed Feb 24 2016 00:00:00 GMT-0500 (Eastern Standard Time)
02/24/2016
对于我的申请,我无法更改日期格式,即 testInfoSelect.testDate,在本例中为 "Wed. February 24, 2016"。
我做了什么:
dateString String value representing a date. The string should be in a format recognized by the Date.parse() method (IETF-compliant RFC 2822 timestamps and also a version of ISO8601).
MDN文档中最相似的日期格式是这样的:
Date.parse('Wed, 09 Aug 1995 00:00:00 GMT');
在不改变"Wed. February 24, 2016"
格式的情况下,如何在FF中得到正确的结果谢谢
如@adeno 所述,黑客可以:
new Date("Wed. February 24, 2016".replace('.', ''));
或
new Date("Wed. February 24, 2016".replace('.', ','));
你的情况:
new Date(date.replace('.', ''));
要获取 GMT 时间,您可以执行以下操作:
> new Date(date.replace('.', '') + " GMT");
< Date 2016-02-24T00:00:00.000Z
FF、Chrome 和 Opera 的结果:
火狐:
▶ new Date("Wed. February 24, 2016".replace('.', '') + " GMT");
⯇ Date 2016-02-24T00:00:00.000Z
Chrome:
> new Date("Wed. February 24, 2016".replace('.', '') + " GMT");
<- Wed Feb 24 2016 01:00:00 GMT+0100 (CET)
歌剧:
>>> new Date("Wed. February 24, 2016".replace('.', '') + " GMT");
[+] Wed Feb 24 2016 01:00:00 GMT+0100