-1

i have a course database which includes starting and ending date and time i have to compare the end date and time with current (system) date and time to know weather the course is expired or not if the current time is lapsed with end time

the stored format is like this "endDate": 03-09-22 "endTime": 5:00 PM can i compare date like this

let cTime=moment().format('hh:mm A');
let cDate=moment().format('DD-MM-YY');
if(endDate>cDate)
{
   console.log('yes')
}
else
console.log('no');

i am getting no in the output

1 Answers1

0

convert endDate to moment date like

endDate = moment(endDate).format('DD-MM-YY');

then compare

if(endDate>cDate)
{
   console.log('yes')
}