//Wed, 04 Apr 2012 21:09:16 GMT
to = moment.utc().add('m', 60).toDate();
seconds = moment.diff(to, 'seconds');
I'm trying to get the seconds from the current time in UTC and another date that is set in UTC.
I'm using moment.diff
- the above code returns a negative value of -3600 instead of 3600.
Is this the correct way to do this? Shouldn't the negative only be if the date has passed?
That should be clarified in the docs.
If the moment is earlier than the one you are diffing, it should be negative. If it is after the one you are diffing, it will be positive.
Think of it this way...
var a = moment(),
b = moment().add('hours', 1);
a.diff(b); // a - b
b.diff(a); // b - a
Most helpful comment
That should be clarified in the docs.
If the moment is earlier than the one you are diffing, it should be negative. If it is after the one you are diffing, it will be positive.
Think of it this way...