解决方式:
以下两种日期格式均支持:
let date1 = '2023-12-01'
let date2 = '2023/11/30'
调用方法:
this.getDateDifference(date1.date2);
方法代码:
getDifferTime(startDate, endDate) {
let startTime = new Date(Date.parse(startDate.replace(/-/g, "/"))).getTime();
let endTime = new Date(Date.parse(endDate.replace(/-/g, "/"))).getTime();
let dates = Math.abs((startTime - endTime)) / (1000 * 60 * 60 * 24);
return dates; // 返回1
}