MomentJS - Seconds


Advertisements

This method will give the number of seconds in the duration. The value returned will be between 0-59. If you want proper length of seconds in that duration make use of moment.duration().asSeconds().

Syntax

moment.duration().seconds();
moment.duration().asSeconds();

Example

var a = moment.duration(20000).seconds();

Output

If you want to display the length of seconds in a duration make use of moment.duration().asSeconds() as follows −

Example

var a = moment.duration(600).asSeconds();

Output

Seconds
momentjs_durations.htm
Advertisements