I'm writing a service in node js. I have used moment js for time related solutions. I want to calculate the time difference between two times. Here is my snippet and it's not giving me the desired output :
var now = moment('11:08:30',"H:mm:ss");
var prev = moment('11:07:30', "H:mm:ss");
var result = moment(now.diff(prev)).format("H:mm:ss");
console.log(result);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/moment.min.js"></script>
As per my understanding, I think the difference between 11:08:30
and 11:07:30
should come out as 00:01:00 but instead the output is coming as 5:31:00
. I don't understand why this is happening. How do I fix it so that the output is 00:01:00
i.e 1 minute ?