moment get dates between two dates code example
Example 1: momentjs number of days between two dates
var given = moment("2018-03-10", "YYYY-MM-DD");
var current = moment().startOf('day');
moment.duration(given.diff(current)).asDays();
Example 2: moment date difference in days
moment(new Date()).diff(moment(new Date()), 'days')
Example 3: compare two dates using moment
moment('2010-10-20').isAfter('2010-01-01', 'year');
moment('2010-10-20').isAfter('2009-12-31', 'year');
Example 4: moment js difference between two dates
var admission = moment('{date1}', 'DD-MM-YYYY');
var discharge = moment('{date2}', 'DD-MM-YYYY');
discharge.diff(admission, 'days');
Example 5: moment js date between two dates
target.isBetween(start, finish, 'days', '()')
target.isBetween(start, finish, 'days', '(]')
target.isBetween(start, finish, 'days', '[)')
target.isBetween(start, finish, 'days', '[]')