0

I have a website where I am implementing datepickers, the site is for uploading school tasks, then I have a datepicker for the date on which it was commissioned (homeWorkDate) and another for the date that it should be delivered (reviewDate). The detail is more noticeable when you want to edit a task, at the time of loading the dates it always takes as reference today and not its date (baseDate).

I have tried with defaultDate and setDate

function setCalendarsDate(baseDate, homeWorkDate, reviewDate) {
    $("#fmt_d")
        .datepicker({
            defaultDate: baseDate,
            maxDate: homeWorkDate
        })
        .datepicker("setDate", homeWorkDate)

    $("#fmt_e")
        .datepicker({
            defaultDate: baseDate,
            minDate: reviewDate
        })
        .datepicker("setDate", reviewDate)
}
Domingo
  • 1
  • 1

1 Answers1

0

Ok, I think this may help, credit to https://stackoverflow.com/a/751843/604259

Seems you may need to pass an object as second parameter.

$('#dateselector').datepicker("setDate", new Date(2008,9,03) );

Good-luck

Stephane Gosselin
  • 9,030
  • 5
  • 42
  • 65
  • Not necessary to pass date object. Right format will work too. https://api.jqueryui.com/datepicker/#method-setDate – Ankur Jul 16 '19 at 04:21