I am trying to set the End date for registration to be 1 day before the event start date. For this, I am trying below function but still the end day is getting selected on the start of day event. E.g. If event_start_date
is 1st May then I want date-picker to allow event_registration_deadline
max to be on 30th April but in actual the date-picker is allowing to select 1st May but disabling date after that. Function:
if(jQuery( "#event_start_date" ).length > 0)
{
jQuery('input#event_start_date').datepicker({
format : 'yyyy-mm-dd',
autoclose : true,
todayHighlight: true
}).on('changeDate', function(){
var aDayBefore = new Date(jQuery(this).val()-1);
jQuery('#event_registration_deadline').datepicker('setEndDate', aDayBefore);
});
}
I am trying to get this by setting up -1 on below line code:
var aDayBefore = new Date(jQuery(this).val()-1);