MomentJS - Hours


Advertisements

This method will display the hours in the duration. The value returned will be between 0-23. In case you need the proper length of hours in that duration, make use of moment.duration().asHours();

Syntax

moment.duration().hours();
moment.duration().asHours();

Example

var h = moment.duration(500, "hours").hours();
var ashrs = moment.duration(500, "hours").asHours();

Output

Hours
momentjs_durations.htm
Advertisements