Compare two dates in java scriptIntroduction
I have written this code on ‘
Compare Two Dates’. By using JavaScript, The Date object is also used to compare two dates.
The following example compares today's date with the 02nd February 2010:
var yourDate=new Date();
yourDate.setFullYear(2010,02,02);
var toDay = new Date();
if (yourDate>toDay)
{
alert("Today is before 2nd February 2010");
}
else
{
alert("Today is after 2nd February 2010");
}