How can I humanize this complete duration in moment.js / javascript

后端 未结 4 1926
遇见更好的自我
遇见更好的自我 2020-12-03 15:05

I have a \'time remaining\' counter in place for file uploads. The remaining duration is calculated and converted into milliseconds like so:

var elapsedTime         


        
4条回答
  •  星月不相逢
    2020-12-03 15:46

    You should give a try on this plugin: moment-duration-format

    Its syntax is very convenient:

    var moment = require('moment');
    require("moment-duration-format");
    moment.duration(32832, "seconds").format("h [hrs]: m [min]: s [sec]")
    // => 9 hrs: 7 min: 12 sec" 
    

提交回复
热议问题