1、获取两个日期的周期数
getCycle(startTime,endTime){//获取周期
const start = new Date(startTime);
const end = new Date(endTime);
let years = end.getFullYear() - start.getFullYear();
let months = end.getMonth() - start.getMonth();
return years * 12 + months;
},复制
2、获取两个日期的差值
//计算间隔天数
const start = new Date(this.startTime);
const end = new Date(this.endTime);
let dayNumber=Math.ceil((end - start) / (1000 * 60 * 60 * 24));
复制