why momentjs isBetween function is not behaving as expected for the year 2020

moment('2020-11-15').isBetween('2020-11-15', undefined, null, '[]');

This one returns false because the order of the 2 dates. Above command means you are checking if targetDate >= 2020-11-15 && targetDate <= today(2020-11-05) which is always false until 2020/11/15

since moment(undefined) evaluates as moment() which is the current date, you need to change the 1st and 2nd argument.


// date `A` should be always earlier date than date `B`
moment('2020-11-15').isBetween(A, B, C, D);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top