格式化MomentJS持续时间超过24小时 [英] Formatting MomentJS duration above 24 hours

查看:79
本文介绍了格式化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小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆