JSFiddle - React, Tailwind, and code Playground

by Karl Hui

JavaScript

//How to check if a 'date' is the same
var date1 = Date("2014-05-02");
var date2 = new Date();

//Are they the same year?
if (date1.getYear() == date2.getYear()) {
    console.log("they're the same year.");
}

//Are they the same month?
if (date1.getMonth() == date2.getMonth()) {
    console.log("they're the same month.");
}

//Are they the same day of the month?
if (date1.getDate() == date2.getDate()) {
    console.log("they're the same date.");
}