问题
This always returns "invalid date". It works in Chrome and Safari, but in IE I always get an invalid date.
The code in question:
var utcMoment = moment.utc(value.Timestamp);
value.Timestamp
is in this format: "17 Sep 15 19:55:37"
Should I be using a different date format? I am unsure how to proceed.
回答1:
You can explicitly define the format when creating the moment.
var utcMoment = moment.utc("17 Sep 15 19:55:37", "DD MMM YY HH:mm:ss");
console.log(utcMoment);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js"></script>
来源:https://stackoverflow.com/questions/32660040/how-can-i-stop-getting-an-invalid-date-in-ie-with-moment-js