ie8以下,new Date() 特定一天,返回NaN的问题的处理
function getDate(dateStr) { var isoExp = /^\s*(\d{4})-(\d\d)-(\d\d)\s*$/; //正则 var date = new Date(NaN); var parts = isoExp.exec(dateStr); //正则验证 if (parts) { var month = Number(parts[2]); //设置时间 date.setFullYear(parts[1], month - 1, parts[3]); //判断是否正确 if (month != date.getMonth() + 1) { date.setTime(NaN); } } return date; }