moment.js计算两个时间差值
2021-02-02 本文已影响0人
Poppy11
minute为分钟,可更改为小时,秒或毫秒,具体看官方说明
const m1 = moment(start)
const m2 = moment(end)
var duration = moment.duration(m2.diff(m1))
var hours = duration.asHours();
if (hours - 11.5 < 1) {
hours = 0
} else {
hours -= 11.5
}
return Math.floor(hours)