Seconds1.6.0+
moment.duration().seconds();
moment.duration().asSeconds();
To get the number of seconds in a duration, use moment.duration().seconds()
.
It will return a number between 0 and 59.
moment.duration(500).seconds(); // 0
moment.duration(1500).seconds(); // 1
moment.duration(15000).seconds(); // 15
If you want the length of the duration in seconds, use moment.duration().asSeconds()
instead.
moment.duration(500).asSeconds(); // 0.5
moment.duration(1500).asSeconds(); // 1.5
moment.duration(15000).asSeconds(); // 15
当前内容版权归 momentjs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 momentjs.com .