I get incorrect results when trying to find numeric difference between two dates:
var startDate = moment( $('[name="date-start"]').val(), "DD.MM.YYYY"), // $('[name="date-start"]').val() === "13.04.2016"
endDate = moment( $('[name="date-end"]' ).val(), "DD.MM.YYYY"); // $('[name="date-end"]').val() === "28.04.2016"
var diff = startDate.diff(endDate);
console.log( moment(diff).format('E') );
Between 13.04.2016
and 28.04.2016
I shouldn't get that difference is 3 or 2 days...
I've tried to multiple combinations:
- swap
startDate.diff(endDate)
withendDate.diff(startDate)
format('E')
with something I've come up searching the SO
Result: all the time I get that difference is 3 or 2 days.
What am I doing wrong?