本文介绍了格式化MomentJS持续时间超过24小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想格式化一个总的工作时间,例如 49.75 : 49:45 .
I would like to format a summed up total working hours e.g. 49.75 to this: 49:45.
当我使用这样的持续时间时:
When I use duration like this:
const dur = moment.duration(49.75, 'hours').asMilliseconds(); moment.utc(dur).format("HH:mm:ss") // 01:45:00我将收到 01:45:00 而不是 49:45:00
是否有一种格式(而不是 HH )持续时间格式而又不减少天数?
Is there a way to format (instead of HH) duration without dropping the days?
推荐答案我建议您答案.
您可以添加持续时间的格式,并且该格式可以使用超过24小时.
You can add a format for the duration, and it works for greater than 24 Hour.
function(input) { input = input || ''; var out = ''; var dur = moment.duration(input, 'minutes'); return dur.format('HH:mm:ss'); };我希望它能为您提供帮助!
I hope it can help you!
此代码使用持续时间格式插件!
更多推荐
格式化MomentJS持续时间超过24小时
发布评论