value为取出的时间(Wed Apr 01 2020 00:00:00 GMT+0800 (中国标准时间))
onstartDate(value){
const d = new Date(value)
var strDate = d.getDate()
var month = d.getMonth() + 1
var hours = d.getHours()
var minutes = d.getMinutes()
var seconds = d.getSeconds()
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
if(hours >= 1 && hours <= 9){
hours = "0" + hours;
}
if(minutes >= 1 && minutes <= 9){
minutes = "0" + minutes;
}
if(seconds >= 1 && seconds <= 9){
seconds = "0" + seconds;
}
this.oldDate = d.getFullYear() + '-' + month + '-' + strDate+ ' ' + hours +':'+ minutes+':'+seconds
}
计算月份相差
allmoney(oldstartTime,oldendTime){
let startTime=newDate(oldstartTime);
let endTime=new Date(oldendTime);
var date2Mon;
var startDate=startTime.getDate()+startTime.getHours()/24+startTime.getMinutes()/24/60;
var endDate=endTime.getDate()+endTime.getHours()/24+endTime.getMinutes()/24/60;
if(endDate>=startDate){
date2Mon=0;
}else{
date2Mon=-1;
}
return (endTime.getYear()-startTime.getYear())*12+endTime.getMonth()-startTime.getMonth()+date2Mon;
},