Convert milliseconds to hours and minutes using Momentjs

前端 未结 11 2445
滥情空心
滥情空心 2020-12-09 15:00

I am new to Momentjs. I am trying to use it to convert milliseconds to hours and minutes. Below, x is milliseconds

x = 433276000
var y = moment.duration(x, \         


        
11条回答
  •  一向
    一向 (楼主)
    2020-12-09 15:13

    This seems unsupported per this SO. Following this github issue, there's a moment-to-countdown plugin that you may be able to use.

    But it seems you may want Countdown.js for this in the first place.

    countdown(0, 433276000, countdown.HOURS | countdown.MINUTES).toString();
    

    Note this does not take into account leap seconds, or leap anything for that matter, as it fixes to the Unix epoch (so it's not a pure time interval).

提交回复
热议问题