comparing dates in js code example
Example 1: compare dates in js
var date1 = new Date('December 25, 2017 01:30:00');
var date2 = new Date('June 18, 2016 02:30:00');
if(date1.getTime() === date2.getTime()){
}
if(date1.getTime() > date2.getTime()){
}
Example 2: compare dates in javascript
var date1 = new Date('December 25, 2017 01:30:00');
var date2 = new Date('June 18, 2016 02:30:00');
if(date1.getTime() === date2.getTime()){
}
if(date1.getTime() > date2.getTime()){
}
Example 3: compare date javascript
start = startDate.getTime();
end = endDate.getTime();
current = date.getTime();
if (start <= current && current <= end) {
}
Example 4: how to compare dates js
const x = new Date('2013-05-22');
const y = new Date('2013-05-23');
console.log('x < y', x < y);
console.log('x > y', x > y);
console.log('x === y', x === y);
console.log('+x <= +y', +x <= +y);
console.log('+x >= +y', +x >= +y);
console.log('+x === +y', +x === +y);