How to get the difference between 2 times? Example:
var now = "04/09/2013 15:00:00";
var then = "04/09/2013 14:20:30";
//expected result:
"00:39:30"
I tried:
var now = moment("04/09/2013 15:00:00");
var then = moment("04/09/2013 14:20:30");
console.log(moment(moment.duration(now.diff(then))).format("hh:mm:ss"))
//outputs 10:39:30
What is "10" there? I am at utc-0300. Result of moment.duration(now.diff(then))
is a duration with correct internal values:
days: 0
hours: 0
milliseconds: 0
minutes: 39
months: 0
seconds: 30
years: 0
How to convert a momentjs duration to a time interval? I can use:
duration.get("hours") +":"+ duration.get("minutes") +:+ duration.get("seconds")
But is there something more elegant? now
is:
Tue Apr 09 2013 15:00:00 GMT-0300 (E. South America Standard Time)…}
And moment(moment.duration(now.diff(then)))
is:
Wed Dec 31 1969 22:39:30 GMT-0200 (E. South America Daylight Time)…}
The value is -0200 because for 31/12/1969 daylight saving time was used.