Event though ,oment.js does not provide such functionality, if you come here and you are already using moment.js, try this:
function formatDuration(ms) {
var duration = moment.duration(ms);
return Math.floor(duration.asHours()) + moment.utc(duration.asMilliseconds()).format(":mm:ss");
}
You will get something like x:xx:xx.
In the case you may want to skip the hour, when the duration is only < 60minutes.
function formatDuration(ms) {
var duration = moment.duration(ms);
if (duration.asHours() > 1) {
return Math.floor(duration.asHours()) + moment.utc(duration.asMilliseconds()).format(":mm:ss");
} else {
return moment.utc(duration.asMilliseconds()).format("mm:ss");
}
}
This workaround in moment was introduced in this Issue.