As Unit of Time2.1.0+

  1. moment.duration().as(String);

As an alternate to Duration#asX, you can use Duration#as('x'). All the shorthand keys from moment#add apply here as well.

  1. duration.as('hours');
  2. duration.as('minutes');
  3. duration.as('seconds');
  4. duration.as('milliseconds');

Invalid durations return NaN for all units.