I have a function that is looking to determine if a date is in the past. It uses moment to take the difference between these two dates. However when the given date is tomorrow the difference is 0 when I'd expect for it to be 1.
const isPastDate = (date) => {
if (date) {
console.log(date);
const givenDate = moment(date);
const today = moment();
console.log("givenDate => ", givenDate);
console.log("today => ", today);
const diff = today.diff(givenDate, "days");
console.log("diff => ", diff);
const result = diff >= 0;
return result;
}
};