H
I need to customize two datepickers.
First shold have:
- minDate: last ten days of this month (or if easier: 20th of this month)
- maxDate: 10th of next month
I can only set then as given in "manual" like this: +1m +2w +5d. But that is not good in my case since I do not need to go relative to current data.
Any idea?
I have tried this with no luck:
// temp vars used below
var currentTime = new Date()
// DATEPICKER CURENT MONTH - all fields with class: datepicker_current_month
$(".datepicker_current_month").datepicker({
dateFormat: 'dd.mm.yy',
// minDate: '+10d',
minDate: new Date(currentTime.getYear(), currentTime.getMonth(), 20),
maxDate: '+3w'
});
BR. Anders
UPDATE - Solution I used the answer from undertakeror and it works just fine. Thnaks for the answer :-)
// temp vars used below
var currentTime = new Date();
var startDateFrom = new Date(currentTime.getFullYear(), currentTime.getMonth() +1, -10); // 10 days before next month
var startDateTo = new Date(currentTime.getFullYear(), currentTime.getMonth() +1, -1); // one day before next month
var endDateFrom = new Date(currentTime.getFullYear(), currentTime.getMonth() +1, 3); // 3rd of next month
var endDateTo = new Date(currentTime.getFullYear(), currentTime.getMonth() +1, 10); // 10th of next month
// DATEPICKER CURENT MONTH - all fields with class: datepicker_current_month
$(".datepicker_current_month").datepicker({
dateFormat: 'dd.mm.yy',
minDate: startDateFrom,
maxDate: startDateTo
});