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)
with endDate.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? Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…