Ess
Ess

Reputation: 3370

MomentJS - How to get 00:01:00.02 format from seconds.milliseconds value?

My value is 60.02 so how can I transform it in hours:minutes:seconds.milliSeconds format to get 00:01:00.02 format using the momentJS library?

Upvotes: 0

Views: 462

Answers (1)

BraveButter
BraveButter

Reputation: 1458

You could use moment duration to format your time string

let seconds = '60.02';
moment.utc(moment.duration({
    seconds: seconds
}).asMilliseconds()).format('HH:mm:ss:SS');

For the whole moment duration docs see here

Upvotes: 3

Related Questions