I want to check if the event date is today. If yes then show some text. If target event date does not pass then show some text and also check if the event date already passed. here is my code
var evnt_date = "2018-09-18";
wishTime(evnt_date);
function wishTime(evnt_dt){
var today = new Date();
var evnt = new Date(evnt_dt);
if(Date.parse(evnt) == Date.parse(today)){
$("#header-slogan").html($("#header-slogan").html());
}else if(Date.parse(evnt) > Date.parse(today)){
$("#header-slogan").html($("#header-slogan").html() + " In Advance");
}else if(Date.parse(evnt) < Date.parse(today)){
$("#header-slogan").html("Belated " + $("#header-slogan").html());
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="header-slogan">Wish you...</div>
In this code you can check if event date is today, then it will show belated. After debug by displaying the two dates i.e today, evnt, I saw it compares time part also. So is there any way to compare date only? I dont want to use seperate plugin for that.