Answers for "Compare dates without time using date strings"

0

Compare dates without time using date strings

let date1 = new Date("2024-01-29T03:34:48.000Z"); // Tue Jan 29 2024 03:34:48 GMT+0000
let date2 = new Date("2024-01-29T15:00:00.000Z"); // Tue Jan 29 2024 15:00:00 GMT+0000
let date1String = date1.toDateString();           // "Tue Jan 29 2024"
let date2String = date2.toDateString();           // "Tue Jan 29 2024"
console.log(date1String === date2String); // Output: true
console.log(date1String < date2String);   // Output: false
console.log(date1String > date2String);   // Output: false
Posted by: Raja MS on February-02-2024

Code answers related to "Compare dates without time using date strings"

Code answers related to "Javascript"

Browse Popular Code Answers by Language