使用传入的两个时间的毫秒差来计算时间
1.计算相差天数
const DifferDayTime = function(startDate, endDate) {
return Math.floor((new Date(endDate).getTime() - new Date(startDate).getTime()) / 86400000)
}
2.计算相差小时数
const DifferHourTime = function(startDate, endDate) {
return Math.floor((new Date(endDate).getTime() - new Date(startDate).getTime()) / 3600000)
}
3.计算相差分钟数
const DifferMinuteTime = function(startDate, endDate) {
return Math.floor((new Date(endDate).getTime() - new Date(startDate).getTime()) / 60000)
}
4.计算相差秒数
const DifferSecondTime = function(startDate, endDate) {
return Math.floor((new Date(endDate).getTime() - new Date(startDate).getTime()) / 1000)
}