I want to impliment the same functionality as in this qeustion JQuery ui - date picker, disabling specific dates , the script working fine(see the code below), but the problem is I am getting Unavailable dates from database, so the dates has a leading zero, ie var unavailableDates = ["90-3-2012", "14-03-2012", "15-03-2012"]; If I test with same dates without leading zero it works, but I want to with leading zero.
How can we format the dates, I am using the exact code from an answer for the above said quesiton , here is the code
<script type="text/javascript"> var unavailableDates = ["9-3-2012", "14-3-2012", "15-3-2012"]; function unavailable(date) { dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear(); if ($.inArray(dmy, unavailableDates) == -1) { return [true, ""]; } else { return [false, "", "Unavailable"]; } } $(function() { $("#iDate").datepicker({ dateFormat: 'dd MM yy', beforeShowDay: unavailable }); }); </script>