as()


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.

duration.as('hours');
duration.as('minutes');
duration.as('seconds');
duration.as('milliseconds');

Invalid durations return NaN for all units.

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.

duration.as('hours');
duration.as('minutes');
duration.as('seconds');
duration.as('milliseconds');

Invalid durations return NaN for all units.