I am trying to compare a date in the jqueryui datepicker.beforeShowDay() to establish whether a day is selectable or not. However it doesn’t seem to work. The code is:
function (d) {
if ((d.getDay() == 0) || (d == $.datepicker.parseDate('yy/mm/dd', '2012/12/25'))) {
return [false, ""];
}
else {
return [true, "2"]
};
}
the first test (getDay) works fine but the second does not:
(d == $.datepicker.parseDate('yy/mm/dd', '2012/12/25')): false
even though
$.datepicker.parseDate('dd/mm/yy', '25/12/2012'): Tue Dec 25 2012 00:00:00 GMT+0000 (GMT Standard Time)
and
d: Tue Dec 25 2012 00:00:00 GMT+0000 (GMT Standard Time)
which look the same to me.
Any ideas?
Use the
formatDatemethod to get it to the string format first then do a comparison of the same type:DEMO