jqueryjquery-uidatepickermaxdatemindate

Jquery UI Datepicker adds a month to minDate and maxDate


I have a Jquery UI datepicker on my site, but when i choose minDate and maxDate it adds a month to each variable, why is that and how do i fix it?

var startDate = new Date(2014, 2, 24);
var endDate = new Date(2014, 3, 24);

FIDDLE


Solution

  • If you date is taken from the database the easiest way to do so

    var startDate = new Date(2014, 2, 24);
    var endDate = new Date(2014, 3, 24);
    
    startDate.setMonth(startDate.getMonth()-1);
    endDate.setMonth(endDate.getMonth()-1);