future and past date validation in moment js

 let bodyDate = moment(“2022-05-10”, “YYYY-MM-DD”, true);

let todayDate = moment(moment().format(“YYYY-MM-DD”), “YYYY-MM-DD”, true);

if (bodyDate < todayDate) {
console.log(‘expired date’)
}else{
console.log(‘future date’)
}

Leave a Comment

Your email address will not be published. Required fields are marked *