ie9 +, the chrome firefox opera string used to Date new Date ( "2014-06-01"); all is ok.
But returned in ie7, ie8 under NaN
Solved by the following method:
function parseISO8601(dateStringInRange) {
var isoExp = /^\s*(\d{4})-(\d\d)-(\d\d)\s*$/,
date = new Date(NaN), month,
parts = isoExp.exec(dateStringInRange);
if(parts) {
month = +parts[2];
date.setFullYear(parts[1], month - 1, parts[3]);
if(month != date.getMonth() + 1) {
date.setTime(NaN);
}
}
return date;
}
parseISO8601('2014-06-01');
Reproduced in: https: //www.cnblogs.com/lynn-lin/p/3817965.html