javascirpt compare date without time code example
Example 1: compare date javascript
// solution is convert date to time by getTime()
start = startDate.getTime();
end = endDate.getTime();
current = date.getTime();
if (start <= current && current <= end) {
// do something here
}
Example 2: javascript compare dates
let d1 = new Date();
let d2 = new Date();
// can use >, <, <=, <=
d1 > d2
d1 >= d2
// == won't work so can use this:
(d1 >= d2) && (d2 >= d1)