Skip to content

Instantly share code, notes, and snippets.

@JasvinderSingh1
Created October 27, 2021 11:25
Show Gist options
  • Save JasvinderSingh1/033c99e57f56e91de48720b8ff0b08eb to your computer and use it in GitHub Desktop.
Save JasvinderSingh1/033c99e57f56e91de48720b8ff0b08eb to your computer and use it in GitHub Desktop.
PHP OTPL
// from date to date restrictions
$("#from_date").datepicker({
format: 'dd-mm-yyyy',
//minDate: new Date('02-09-2021'),
//maxDate: new Date(),
autoClose: true,
onSelect: function(dateText) {
var dateMin = $('#from_date').datepicker("getDate");
//var datee = new Date($("#from_date").val());console.log(datee);
var from_date = $("#from_date").val().split('-');
var datee = new Date(from_date[1]+'-'+from_date[0]+'-'+from_date[2]),
yr = datee.getFullYear(),
month = datee.getMonth() < 10 ? '0' + datee.getMonth() : datee.getMonth(),
day = datee.getDate() < 10 ? '0' + datee.getDate() : datee.getDate(),
newDate = day + '-' + (parseInt(month)+1) + '-' + yr;
///console.log(datee); console.log(newDate);
$('#to_date').val('');
$('#to_date').datepicker({});
$('#to_date').datepicker({
format: 'dd-mm-yyyy',
minDate: new Date((parseInt(month)+1) + '-' + day + '-' + yr),
//minDate: datee,
//maxDate: datee.getTime(),
autoClose: true
});
/*$('#datepickers-container').find('.datepicker.active').each(function(){
$(this).removeClass('active');
});*/
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment