Answers for "check two date in javascript"

2

javascript check if two date are ugual

const isSameDate = (dateA, dateB) => {
  return dateA.toISOString() === dateB.toISOString();
};
const r = isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20));
console.log(r); //> true
Posted by: Guest on March-30-2020
20

Javascript compare two dates

var date1 = new Date('December 25, 2017 01:30:00');
var date2 = new Date('June 18, 2016 02:30:00');

//best to use .getTime() to compare dates
if(date1.getTime() === date2.getTime()){
    //same date
}

if(date1.getTime() > date2.getTime()){
    //date 1 is newer
}
Posted by: Guest on July-23-2019

Code answers related to "check two date in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language