利用moment.js来实现距离某个时间的时间差,写了个过滤方法

filterTaskTime(params){
    let x=moment(params);
    let y=moment();  //当下时间
    let duration = moment.duration(y.diff(x,'ms'));   //做差
    let days = duration.get('days');
    let hours = duration.get('hours');
    let mins = duration.get('minutes');
    let ss = duration.get('seconds');
    console.log(days,hours,mins,ss)
    return days + '天' + hours + '小时' + mins +'分钟' + ss +'秒';
},

标签: none

添加新评论