Return the number of milliseconds between January 1, 1970 and given date.
Using Date.Parse Method to compare the Dates:
var fromdt="2013/05/29";
var todt="2013/05/29";
var d = Date.parse(fromdt);
var e = Date.parse(todt);
if(d==e)
{
alert("Both the Dates are equal!");
}
else if(d>e)
{
alert("From date should not be greater than todate!");
}
else if(d<e)
{
alert("Valid Dates");
}
Also using - operator to compare the dates:
var dt_from = new Date("2013/05/25");
var dt_to=new Date("2013/05/24");
if(dt_from-dt_to == 0)
{
alert("Both dates are Equal!");
}
else if(dt_from-dt_to > 0)
{
alert("From date should not be greater than todate!");
}
else if(dt_from-dt_to < 0)
{
alert("Okay!");
}
Also this will provide the difference in milliseconds. Then, what is the difference between the 2 codes?I mean Date.parse and new Date()..Thank you....