美文网首页
moment.js计算两个时间差值

moment.js计算两个时间差值

作者: Poppy11 | 来源:发表于2021-02-02 08:39 被阅读0次

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)

相关文章

网友评论

      本文标题:moment.js计算两个时间差值

      本文链接:https://www.haomeiwen.com/subject/yddrzktx.html