Answers for "check if date string is less than or greater than another date string"

0

check if date string is less than or greater than another date string

const x = new Date('2013-05-23');
const y = new Date('2013-05-23');

// less than, greater than is fine:
console.log('x < y', x < y); // false
console.log('x > y', x > y); // false
console.log('x === y', x === y); // false, oops!

// anything involving '=' should use the '+' prefix
// it will then compare the dates' millisecond values
console.log('+x <= +y', +x <= +y); // true
console.log('+x >= +y', +x >= +y); // true
console.log('+x === +y', +x === +y); // true
Posted by: Guest on August-17-2021

Code answers related to "check if date string is less than or greater than another date string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language