I am trying to compare a date in JS with todays date. This is what my code looks like.
But when I try to compare the date for 01/07/2014 then this is not working.
What am I doing wrong?
var chsRedirectDate = "04/01/2013" ; //new Date("1 Apr 2013");
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){dd='0'+dd};
if(mm<10){mm='0'+mm};
today = mm+'/'+dd+'/'+yyyy;
if (ee_value.toUpperCase() == 'TEST123') && (today >= chsRedirectDate))
var url = "test.php" ;
var newtab = window.open("url", null, "top=190,left=450, dependent=yes, directories=no,location=no,menubar=no,status=no,toolbar=no,titlebar=no,scrollbars=no,width=500,height=250,resizable=yes");
window.close();
newtab.location = url;
newtab.focus();
return false;
}
if (ee_value.toUpperCase() == 'TEST123') && (today < chsRedirectDate))
{
alert('Testing');
}
1 Answer