admin管理员组文章数量:1399944
I wanted to check if momentjs
is able to convert a given number of seconds to a ISO 8601 formatted duration string.
E.g. 1000 seconds will lead to PT16M40S
.
I wanted to check if momentjs
is able to convert a given number of seconds to a ISO 8601 formatted duration string.
E.g. 1000 seconds will lead to PT16M40S
.
- npmjs./package/moment-duration – Dan Wilson Commented Nov 14, 2016 at 14:52
- using a library to replace one line of code is kind of crazy. – Paul Rooney Commented Sep 9, 2019 at 4:21
1 Answer
Reset to default 11You can use toISOString
on the duration:
moment.duration(1000, 'seconds').toISOString() //"PT16M40S"
本文标签: javascriptConvert total seconds to ISO 8601 duration string with momentjsStack Overflow
版权声明:本文标题:javascript - Convert total seconds to ISO 8601 duration string with moment.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744241871a2596827.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论