How i can use beforeShowDay for highlighting days in jQuery UI datepicker. I have the following date array
Array
(
[0] => 2011-07-07
Dates in JS are instances of object Date, so you can't check properly if dates are equal using == or ===.
Simple solution:
var your_dates = [
new Date(2017, 4, 25),
new Date(2017, 4, 23)
];
$( "#some_selector" ).datepicker({
beforeShowDay: function(date) {
are_dates_equal = d => d.getTime() === date.getTime();
if(your_dates.some(are_dates_equal)) {
return [true, 'ui-state-active', ''];
}
return [true, '', ''];
}
})