isToday

Php date in js and checking is taoday

by XcsN

JavaScript

function isToday(td) {
    var d = new Date();
    return td.getDate() == d.getDate() && td.getMonth() == d.getMonth() && td.getFullYear() == d.getFullYear();
}


var date1 = new Date("2018-07-03 15:00:00".replace(/-/g, "/"));
var date2 = new Date("2018-07-05 12:00:00".replace(/-/g, "/"));
console.log(date1 + ( isToday(date1) ? " is today" : "is not today"));
console.log(date1 + ( isToday(date2) ? " is today" : "is not today"));