I'm using jquery datepicker for selecting some dates, but I don't want to show the current month, just the previuos months. How can I get it?
At the moment I got the next code, but how can I select all the days of the last months?
$("#toDate").datepicker({
maxDate: "-1M",
dateFormat: 'dd/mm/yy',
firstDay: 1,
onSelect: function(selected) {
var today = getDate();
alert(today);
$("#fromDate").datepicker("option", "maxDate", selected)
}
});
To my knowledge, the only way to get all the day of the previous month is by setting maxDate to the last day of the previous month.
var d = new Date(); // current date
d.setDate(1); // 1st of the month
d.setHours(-1); // one hour before the 1st of the month (last day of previous month)
$("#toDate").datepicker({
maxDate: d,
dateFormat: 'dd/mm/yy',
firstDay: 1,
onSelect: function(selected) {
var today = getDate();
alert(today);
$("#fromDate").datepicker("option","maxDate", selected)
}
});
Js Fiddle : https://jsfiddle.net/ua2oc347/2/