Moment.js 文档

1.6.0+

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

要获取持续时间中的秒数,请使用 moment.duration().seconds()

它将返回 0 到 59 之间的数字。

moment.duration(500).seconds(); // 0
moment.duration(1500).seconds(); // 1
moment.duration(15000).seconds(); // 15

如果你想要持续时间的长度(以秒为单位),请改用 moment.duration().asSeconds()

moment.duration(500).asSeconds(); // 0.5
moment.duration(1500).asSeconds(); // 1.5
moment.duration(15000).asSeconds(); // 15