http://jsfiddle.net
datepicker не читает второй
var daysArray2var from = daysArray1 + "," + daysArray2;
а с одним работает как надо
var from = daysArray1;
и так работает
var from = daysArray2;
вот код
var start1 = '08/12/2016',
end1 = '08/01/2017';
var stArr1 = start1.split('/'),
endArr1 = end1.split('/');
var daysArray1 = [];
var date1 = new Date(stArr1[2], parseInt(stArr1[1]) - 1, parseInt(stArr1[0]));
while (true) {
var year = date1.getFullYear(),
month = date1.getMonth(),
day = date1.getDate();
daysArray1.push(("0" + day).slice(-2) + '/' + ("0" + (month + 1)).slice(-2) + '/' + year);
date1.setDate(date1.getDate() + 1);
if (day == endArr1[0] && month == endArr1[1] - 1 && year == endArr1[2]) {
break;
}
}
var start = '11/01/2017',
end = '11/02/2017';
var stArr2 = start.split('/'),
endArr2 = end.split('/');
var daysArray2 = [];
var date = new Date(stArr2[2], parseInt(stArr2[1]) - 1, parseInt(stArr2[0]));
while (true) {
var year = date.getFullYear(),
month = date.getMonth(),
day = date.getDate();
daysArray2.push(("0" + day).slice(-2) + '/' + ("0" + (month + 1)).slice(-2) + '/' + year);
date.setDate(date.getDate() + 1);
if (day == endArr2[0] && month == endArr2[1] - 1 && year == endArr2[2]) {
break;
}
}
var from = daysArray1 + "," + daysArray2; // 3
var active_dates = from;
document.getElementById('aaa').innerHTML = active_dates;
$("#datepicker").datepicker({
format: "dd/mm/yyyy",
todayHighlight: true,
maxViewMode: 0,
beforeShowMonth: 1,
beforeShowDay: function(date) {
var d = date;
var day = d.getDate();
var curr_date = "0" + day;
var month = d.getMonth() + 1; //Months are zero based
var curr_month = "0" + month;
var curr_year = d.getFullYear();
if (curr_date == 00) {
curr_date = 10;
}
if (curr_date.length > 2) {
curr_date = (curr_date).slice(1);
}
if (curr_month == 00) {
curr_month = 12;
}
if (curr_month.length > 2) {
curr_month = (curr_month).slice(1);
}
var formattedDate = curr_date + "/" + curr_month + "/" + curr_year
if ($.inArray(formattedDate, active_dates) != -1) {
return {
classes: 'booked '
};
}
return;
}
});