console.log(Date.parse('COVINGTONOFFICE-2')) // 981003600000
console.log(new Date('COVINGTONOFFICE-2').toDateString()) // Thu Feb 01 2001
为什么这会返回有效日期?我错过了什么?
如果我想解析一个字符串,例如“2018 年 11 月 26 日星期一 18:03:33 GMT-0500(东部标准时间)”,并将其正确解析为日期,但上面的“COVINGTONOFFICE-2”失败日期测试,如果不将我自己的正则表达式组合在一起,我将如何以正确的方式进行?
这是我尝试过的:
console.log(moment('COVINGTONOFFICE-2').isValid()) // true
console.log(moment.isDate('COVINGTONOFFICE-2')) // false... good!
// so now I want to make sure that a date that has been stringified is still able to be parsed as valid date
console.log(Date.parse('Mon Nov 26 2018 18:03:33 GMT-0500 (Eastern Standard Time)')) // true
console.log(moment.isDate('Mon Nov 26 2018 18:03:33 GMT-0500 (Eastern Standard Time)')) // false... damn
BIG阳
相关分类