Formatting MomentJS duration above 24 hours

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!


I think you cannot use format but build it manually:

var dur = moment.duration(49.75, 'hours');
var hours = Math.floor(dur.asHours());
var mins  = Math.floor(dur.asMinutes()) - hours * 60;
var sec   = Math.floor(dur.asSeconds()) - hours * 60 * 60 - mins * 60;

var result = hours + ":" + mins + ":" + ((sec > 9) ? sec : ("0"+sec));
console.log(result); // 49:45:00

Fiddle


Hope someone will find more elegant way