js - Date ie兼容 ie 不识别 `-`

js - Date ie兼容 ie 不识别 -

ie 11

ie 不识别 -

console.log(moment().year()+'/'+(moment().month() + 1)+'/01 00:00:00',new Date(moment().year()+'/'+(moment().month() + 1)+'/01  00:00:00')) 
// 2022/3/01 00:00:00 Tue Mar 01 2022 00:00:00 GMT+0800 (中国标准时间)


console.log(moment().year()+'-'+(moment().month() + 1)+'-01 00:00:00',new Date(moment().year()+'-'+(moment().month() + 1)+'-01  00:00:00'))
// 2022-3-01 00:00:00 Invalid Date

console.log('2022-3-01 00:00:00'.replace(/-/g,'/')) // 2022/3/01 00:00:00
posted @ 2022-03-01 17:44  zc-lee  阅读(76)  评论(0编辑  收藏  举报