I want to ask users for a date range using bootstrap datetimepicker. There is a field for the start date and another one for the end date, and they\'re initialized to the da
Based on the Linked Pickers example in the Bootstrap datetimepicker documentation, this should work.
Start:
.on('dp.change', function (selected) {
end.data("DateTimePicker").minDate(selected.date);
});
End:
.on('dp.change', function (selected) {
start.data("DateTimePicker").maxDate(selected.date);
});
Note:
On older versions of Bootstrap datetimepicker (less than v4), use .setMinDate
and .setMaxDate
Try to use:
$('.datepickerProjectDate').data("DateTimePicker").minDate('2018-09-15');
Start Date
.on('dp.change', function (selected) {
end.data("DateTimePicker").minDate(selected.date);
});
End Date
.on('dp.change', function (selected) {
start.data("DateTimePicker").maxDate(selected.date);
});
Package Upgrade : The date timepicker package has been upgraded to latest version where we can use 'maxDate()' in place of 'setMaxDate()' and 'minDate()' inplace of 'setMinDate()' as the recent options consider even time in hrs and mins while providing maxDate/minDate option.