$(document).ready(function () {
$("#end").datepicker({
dateFormat: "dd-M-yy",
minDate: 0,
onSelect: function () {
var start = $('#start');
var startDate = $(this).datepicker('getDate');
startDate.setDate(startDate.getDate() - 7);
start.datepicker('option', 'minDate', startDate);
start.datepicker('option', 'maxDate',$(this).datepicker('getDate'));
}
});
$('#start').datepicker({
dateFormat: "dd-M-yy"
});
});
This block of code initializes datepickers in jQuery or Bootstrap with the END date set as the current date and the START date set as 7 days prior to the END date.