I am using bootstrap datepicker.I need to highlight some random dates.
For Example:
I need to highlight the dates like 1,3,8,20,21,16,26,30. Could you please tel
this is how i am highlighting all days except the days in "user_busy_days" array.
Bootstrap date-picker has beforeShowDay prop, which gets executed for each day of month [42 times max], so i just check if the day which is being rendered is in my array , and if it is present in array i highlight it with a gray color else i just highlight it with green color .
I hope it will do the trick.
var today = new Date();
var today_formatted = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+('0'+today.getDate()).slice(-2);
var user_busy_days = ['2017-12-09','2017-12-16','2017-12-19'];
$('#datetimepicker12').datepicker({
inline: true,
sideBySide: true,
beforeShowDay: function (date) {
calender_date = date.getFullYear()+'-'+(date.getMonth()+1)+'-'+('0'+date.getDate()).slice(-2);
var search_index = $.inArray(calender_date, user_busy_days);
if (search_index > -1) {
return {classes: 'non-highlighted-cal-dates', tooltip: 'User available on this day.'};
}else{
return {classes: 'highlighted-cal-dates', tooltip: 'User not available on this day.'};
}
}
});