当前位置: 代码迷 >> 综合 >> IE 兼容性 newDate(“2020-01-2”) 转换为null
  详细解决方案

IE 兼容性 newDate(“2020-01-2”) 转换为null

热度:1   发布时间:2024-01-27 05:21:37.0

IE下面使用

var t = new Date(“2019-02-22”)转换失败。
这种格式的日期在IE下不支持这种转换,需要换成斜杠格式的日期,

如:
var t = new Date(“2019/02/22”)


也可以使用正则来转换
var t = new Date(“2019-02-22”.replace(/-/g, “/”));

  相关解决方案