无法将moment.js格式的日期转换为有效日期

时间:2019-06-10 16:47:26

标签: javascript momentjs

无法使用以下方式将moment.js格式的日期转换为有效日期

new Date('08-Mar-19 06:01 AM') // Gives invalid date in IE

注意:它在IE中不起作用。仅适用于Chrome。

实际上,我是使用moment.js的格式(“ 19年3月8日06:01 AM”)

const date = moment(value, 'YYYY-MM-DD hh:mm:ss.S'); // from "2019-03-08T06:01:52-05:00"
return date.isValid() ? date.format('DD-MMM-YY hh:mm A') : value;

我尝试通过使用moment.js进行解析仍然无法正常工作。

new Date('08-Mar-19 06:01 AM') // Gives invalid date in IE

预期:

new Date('08-Mar-19 06:01 AM');
Fri Mar 08 2019 06:01:00 GMT-0500 (Eastern Standard Time)

实际:

new Date('08-Mar-19 06:01 AM'); // Invalid date

0 个答案:

没有答案