ie浏览器下new Date("2013/04")与new Date("2016-04")会报错:
//将201601格式的字符串转为Date对象,月份从0开始
function convertDate(dateString){
var date=new Date();
date.setFullYear(+dateString.slice(0,4),+dateString.slice(4)-1);
return date;
}
2023-02-24 19:44:55
ie浏览器下new Date("2013/04")与new Date("2016-04")会报错:
//将201601格式的字符串转为Date对象,月份从0开始
function convertDate(dateString){
var date=new Date();
date.setFullYear(+dateString.slice(0,4),+dateString.slice(4)-1);
return date;
}