Formatting MomentJS duration above 24 hours

前端 未结 3 1312
面向向阳花
面向向阳花 2021-02-19 12:10

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         


        
3条回答
  •  终归单人心
    2021-02-19 13:00

    I recommend you this answer.

    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!

    EDIT:

    This code uses duration-format plugin!

提交回复
热议问题