Moment is going to work as a datetime, so both of your dates are going to have a time associated with them.
var inputDiv = document.getElementById('start');
var endDate = moment(inputDiv.innerHTML, "DD/MM/YYYY"); // time of midnight (start of day), locally
var startDate = moment(); // time you run the code
So, endDate.diff(startDate, 'days')
is going to calculate something akin to (tonight at midnight[locally]) - (today, midday[locally])
. There is no full day difference in that equation.
Try either endDate.endOf('day').diff(startDate, 'days')
, or better yet endDate.endOf('day').diff(startDate.endOf('day'), 'days')
.
Or you could just set var startDate = moment().startOf('day');
and use the code you have now.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…