Convert seconds to HH-MM-SS with JavaScript?

前端 未结 30 2045
南旧
南旧 2020-11-22 10:05

How can I convert seconds to an HH-MM-SS string using JavaScript?

30条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 10:36

    --update 2

    Please use @Frank's a one line solution:

    new Date(SECONDS * 1000).toISOString().substr(11, 8)
    

    It is by far the best solution.

提交回复
热议问题