How to compare two dates in JavaScript

How to compare two dates in JavaScript

 

var date = new Date();
console.log(date.getTime());

setTimeout(()=>{
    var date1 = new Date();
    console.log(date1.getTime());
},500);

2021-10-03