Using moment.js how do I give a specific format for a duration

前端 未结 2 1604
别那么骄傲
别那么骄傲 2021-01-20 15:21

Given a duration of a number of seconds coming from an API as duration_seconds = 86485.

(1 day, 0 hours, 1 minute, 1 second)

I was going to use

2条回答
  •  再見小時候
    2021-01-20 16:03

    Maybe you can try this?

    moment(duration).format("DD MMM YYYY hh:mm: a")

    Though you might have to convert your seconds to milliseconds. This can be done by saying duration * 1000.

    Found from this answer: Moment js convert milliseconds into date and time

提交回复
热议问题