格式化MomentJS持续时间超过24小时

编程入门 行业动态 更新时间:2024-10-24 11:17:27
本文介绍了格式化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小时

本文发布于:2023-10-30 22:51:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544233.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:持续时间   小时   MomentJS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!