I am using jQuery for both datepicker and timepicker. I would like to restrict the time(currently it's 9am-5.00pm) based on whether if the date chosen is today and current time as well. For instance, if I select today date's (9th July) at around 1.00pm then the timepicker should restrict to 2.00pm-5.00pm since it wouldn't make sense for 9.00am-1.00pm.
My jquery:
$( "#pickupDate" ).datepicker({
dateFormat: 'dd-mm-yy',
minDate : 0,
onSelect: function (date) {
var date2 = $('#pickupDate').datepicker('getDate');
date2.setDate(date2.getDate() + 1);
//sets minDate to pick up date + 1
$('#deliveryDate').datepicker('option', 'minDate', date2);
// check if current date is today
//set timepicker to be later range of time
var current_date = $('#pickupDate').datepicker({);
console.log(current_date);
}
});
$('#pickupTime').timepicker({
minTime: '9',
maxTime: '5:00pm',
});