Format a moment duration as Hours and Minutes

Just a quick helper on how to format a MomentJS duration correctly as hours and minutes.

moment.utc(moment.duration(4500, "seconds").asMilliseconds()).format("HH:mm")

Result: 01:15

4500 seconds in the above example is 1 hour and 15 minutes.

share