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 +'秒';
}
计算2个时间相差多少年月日
let m1 = moment("2019-11-11"),
m2 = moment("2022-03-11");
let duration = moment.duration(m2.diff(m1));
let { _data } = duration;
console.log(duration);
console.log(
"年:" + _data.years,
"月:" + _data.months,
"日:" + _data.days,
);