Is there a simple way to convert a decimal time (e.g. 1.074 minutes) into mm:ss format using moment.js?

前端 未结 4 1638
無奈伤痛
無奈伤痛 2020-12-16 03:26

I was wondering if there\'s a simple way, using moment.js library, to transform a decimal time interval (for example, 1.074 minutes) into its equivalent \'mm:ss\' value. I a

4条回答
  •  难免孤独
    2020-12-16 04:02

    using just js, here's a really simple and fast way to do this for up to 12 hours:

    function secTommss2(sec){
      return new Date(sec*1000).toUTCString().split(" ")[4]
    }
    

提交回复
热议问题