0 in from 1-9 do not work in the calendar ie all dates are highlighted but that's all from 1 to 9 is not as I understand it, you need a zero but how to add it to the code that would work
("0" + curr_date).slice(-2) I know there is such a function, but it does not work
var active_dates = ["11/12/2016", "13/12/2016", "01/01/2017", "15/01/2017", "16/01/2017"]; $("#datepicker").datepicker({ format: "dd/mm/yyyy", todayHighlight: true, maxViewMode: 0, beforeShowMonth: 1, beforeShowDay: function(date){ var d = date; var curr_date = d.getDate(); var curr_month = d.getMonth() + 1; //Months are zero based var curr_year = d.getFullYear() ; if(curr_month<10)curr_month = "0"+curr_month; if(curr_date<10)curr_date = "0"+curr_month; var formattedDate = curr_date + "/" + curr_month + "/" + curr_year if ($.inArray(formattedDate, active_dates) != -1){ return { classes: 'booked ' }; } return; } }); .booked{ background: #F00!important; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet"/> <link href="http://bsdp-assets.blackcherry.us/1.3.0/datepicker3.min.css" rel="stylesheet"/> <script src="http://bsdp-assets.blackcherry.us/1.3.0/bootstrap-datepicker.min.js"></script> <div id="datepicker"></div> <input type="hidden" id="my_hidden_input">