在js中使用moment将秒转换为多少天多少小时多少分多少秒

let x = 2703750;//单位是秒
var d = moment.duration(x, 'seconds');
console.log(Math.floor(d.asDays()) + '天' + d.hours() + '时' + d.minutes() + '分' + d.seconds() + '秒');

输出结果为31天7时2分30秒

最大单位到天

posted @ 2021-03-31 16:54  何以平天下  阅读(3305)  评论(0编辑  收藏  举报