var disabledDates = [
{from: '2017-07-17', to: '2017-07-20'},
{from: '2017-08-01', to: '2017-08-14'},
]
$('input').datepicker({
beforeShowDay: function(date){
var timestamp = date.getTime()
return [!disabledDates.some(range=>
timestamp <= new Date(range.to).getTime() &&
timestamp >= new Date(range.from + ' 00:00').getTime()
)]
}
});