如果这样写的话,会出现负数24个月,-1天啊
function monthDayDiff(startDate,endDate){
start = new Date(startDate);
let end = new Date(endDate);
end.setDate(end.getDate()+1);
let year=end.getFullYear()-start.getFullYear();
let month=end.getMonth()-start.getMonth();
let day=end.getDate()-start.getDate();
let data = new Array(12*year+month,day) ;
return data;
}
console.log(monthDayDiff('2017-3-3','2019-3-1'));