I want to compare following to dates i.e. d1 with d2:
var d1 = new Date(12,05,2013);
var d2 = "12/05/2013";
convert date to timestamp
DateObject.getTime(); will give timestamp
and convert string to date new Date(d2)
javScript
var d1 = new Date("12/05/2013");
var d2 = "12/05/2013";
console.log(d1.getTime());
console.log(new Date(d2).getTime());
if(d1.getTime() == new Date(d2).getTime()){
//do something
}
To compare two variables you need to use JS operators, consider:
if(d1==d2)
{
//do this
}
else
{
//do this
}
More information on logical operators can be found here: http://www.w3schools.com/js/js_comparisons.asp
d1 object will never compare equal to his d2 string like that.
d1is also incorrect the spec. saysDate(year, month, day [, hrs, mins, secs, ms]);