I know I can do anything and some more envolving Dates with momentjs. But embarrassingly, I\'m having a hard time trying to do something that seems simple: geting the differ
When you call diff
, moment.js calculates the difference in milliseconds.
If the milliseconds is passed to duration
, it is used to calculate duration which is correct.
However. when you pass the same milliseconds to the moment()
, it calculates the date that is milliseconds from(after) epoch/unix time that is January 1, 1970 (midnight UTC/GMT).
That is why you get 1969 as the year together with wrong hour.
duration.get("hours") +":"+ duration.get("minutes") +":"+ duration.get("seconds")
So, I think this is how you should do it since moment.js does not offer format
function for duration. Or you can write a simple wrapper to make it easier/prettier.