Datepicker minDate today and maxDate 31 Dec Next year

datepicker, jquery-ui-datepicker

Solution

1) First get today's using

var today = new Date();

2) Similarly set the `lastDate` as below

var lastDate = new Date(today.getFullYear() +1, 11, 31);

The value in `lastDate` will be like

`lastDate = 31 December, today's year +1`

Finally set the `lastDate` as `maxDate`

var today = new Date();  //Get today's date
var lastDate = new Date(today.getFullYear() +1, 11, 31);  //To get the 31st Dec of next year
$(function() {
  $('.public-holiday-date-pick').datepicker({ 
    minDate: '0',
    yearRange: '-0:+1',
    maxDate: lastDate, //set the lastDate as maxDate
    hideIfNoPrevNext: true
  });
});

JSFiddle

Problem

Try to limit the date selection between today and 31st Dec of next year. ``` $(function() { $('.public-holiday-date-pick').datepicker({ minDate: '0', yearRange: '-0:+1', maxDate: ??? hideIfNoPrevNext: true }); }); ``` How should I define maxDate ? tried few things like '31 12 +1', or just 'last day of next year', did not work.

Original source