gpt4 book ai didi

javascript - 日期.值 = 新日期(日期.值);在 IE11 中不起作用

转载 作者:行者123 更新时间:2023-12-01 00:45:23 28 4
gpt4 key购买 nike

它可以在其他网络浏览器中使用,但 IE11 返回无效日期。
为了调试我使用了下面的代码。

console.log('before - ' + date.value); 
date.value = new Date(date.value);
console.log('after - ' + date.value);

IE11控制台

-1958-08-21 00:00:00.0 之前
之后-无效日期

Chrom 版本 75.0.3770.80
-1958-08-21 00:00:00.0之前
1958 年 8 月 21 日星期四 00:00:00 GMT-0700(太平洋夏令时间)之后

最佳答案

我认为

new Date("1958-08-21 00:00:00.0");

是使用该函数的非标准方式。

new Date("1958-08-21T00:00:00.0");

适用于 IE11。 (我添加了T)。

根据MDN :

A string value representing a date, specified in a format recognized by the Date.parse() method (these formats are IETF-compliant RFC 2822 timestamps and also strings in a version of ISO8601).

关于javascript - 日期.值 = 新日期(日期.值);在 IE11 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57421103/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com