How to disable past dates from the current date on a datetimepicker? I tried few posts for similar question but was unable to achieve it, Below is what I tried
Note: This scripts works when you're using the daterangepicker
library.
If you want to disable the Sat
or Sunday
date on daterangepicker
then put this line of code.
$("#event_start").daterangepicker({
// minDate: new Date(),
minYear: 2000,
showDropdowns: true,
singleDatePicker: true,
timePicker: true,
timePicker24Hour: false,
timePickerIncrement: 15,
drops:"up",
isInvalidDate: function(date) {
//return true if date is sunday or saturday
return (date.day() == 0 || date.day() == 6);
},
locale: {
format: 'MM/DD/YYYY hh:mm A'
}
});
OR if you want to disable the previous date
also with sat
and sun
then uncomment the this line minDate: new Date()
$("#datetimepicker2").datepicker({
dateFormat: "mm/dd/yy",
minDate: new Date()
});
var dateToday = new Date();
$('#datepicker').datepicker({
'startDate': dateToday
});
this works for me,
$(function() { $('.datepicker').datepicker({ startDate: '-0m', autoclose: true }); });