I updated my code with string dates created with new Date and added back in the if statement. This isn't disabling the string or range though. I've added the datepicker code too.
function unavailableDays(date) {
function createDateRange(first, last) {
var dates = [];
for(var j = first; j < last; j.setDate(j.getDate() + 7)) {
dates.push(new Date(j.getTime()));
}
var alwaysDisabled = [new Date("1963-3-10T00:00:00"), new Date("1963-3-17T00:00:00"), new Date("1963-3-24T00:00:00"), new Date("1963-3-31T00:00:00"), new Date("1965-9-18T00:00:00")];
return dates.concat(alwaysDisabled);
}
var disabledDays = createDateRange(new Date("1978-8-10T00:00:00"), new Date("1978-11-5T00:00:00"));
var yy = date.getFullYear(), mm = date.getMonth(), dd = date.getDate();
for (i = 0; i < disabledDays.length; i++) {
if($.inArray(yy + '-' + (mm+1) + '-' + dd,disabledDays) != -1 || new Date() < date) {
return [false];
}
}
return [true];
}
$(document).ready(function (){
$('.selector').datepicker({
inline: true,
dateFormat: 'yy-mm-dd',
constrainInput: true,
changeYear: true,
changeMonth: true,
minDate: new Date(1940, 1-1, 1),
maxDate: new Date(2011, 10-1, 24),
beforeShowDay: unavailableDays,
onSelect: function(dateText, inst) {
$("#img").attr("src", "http://www.example.com" + dateText + ".jpg");
var chosenDates = $.datepicker.parseDate('yy-mm-dd', dateText);
var backToString = $.datepicker.formatDate('MM dd' + ',' + ' yy', chosenDates);
$('.info').html('You are viewing:' + '<br />' +
backToString).addClass('background');
}
});
});