I have two dates date
and meeting.date
coming from two APIs. I want to check, if the dates are equal.
// date = "28.02.2022";
// meeting.date = "2022-02-08 14:30:00";
const firstDate = new Date(`${date.split(".").reverse().join("-")}`);
const secondDate = new Date(`${meeting.date.split(" ")[0]}`)
firstDate.setHours(0,0,0,0);
secondDate.setHours(0,0,0,0);
console.log(firstDate, secondDate, firstDate === secondDate);
This logs me
[Log] Mon Feb 28 2022 00:00:00 GMT+0100 (CET) – Mon Feb 28 2022 00:00:00 GMT+0100 (CET) – false
I expect that to be true? I found the solution, setting the hours to zero here on stackoverflow, but I'd say, that this is gratuitous, as I don't pass the time the Date. Anyhow, what am I doing wrong?