javascript - Convert total seconds to ISO 8601 duration string with moment.js - Stack Overflow

I wanted to check if momentjs is able to convert a given number of seconds to a ISO 8601 formatted dura

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.

Share Improve this question edited Feb 13, 2019 at 12:06 Patrick 2,2453 gold badges23 silver badges36 bronze badges asked Nov 14, 2016 at 14:46 nitte93nitte93 1,8503 gold badges28 silver badges42 bronze badges 2
  • 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
Add a ment  | 

1 Answer 1

Reset to default 11

You can use toISOString on the duration:

moment.duration(1000, 'seconds').toISOString() //"PT16M40S"

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744241871a4564743.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信