C
C
campus12019-02-03 22:43:47
JavaScript
campus1, 2019-02-03 22:43:47

How to find time difference in moment.js?

There are 2 hours:

let endTime = "23:07";
let startTime = "22:07"

How to find the difference between them using moment.js?
Tried like this:
var diff = moment("23:07").unix() - moment("22:07").unix();
moment.utc(moment.duration(diff).asMilliseconds()).format("HH:mm:ss.SSS");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-02-03
@campus1

moment.utc(moment.duration(endTime) - moment.duration(startTime)).format('HH:mm')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question