0

Here's my code and its result:

$(function () {        
        $('.temp').datepicker({
            showWeek: true,
            dateFormat: "dd/mm/yy",
            defaultDate: "27/03/2018",
            changeMonth: true,
            changeYear: true
        });
        $(".temp").datepicker().datepicker("setDate", "26/03/2018");
    });

enter image description here

I want to set my server computer date 26/03/2018 instead of client machine date 19/03/2018.

I tried both functions defaultDate and setDate but it's not working. It still shows the current date as 19/03/2018.

How to set server machine date as current date in jquery datepicker?

Al.G.
  • 4,327
  • 6
  • 31
  • 56
User
  • 1,334
  • 5
  • 29
  • 61

1 Answers1

0

You can use string quantifiers for your default date like:

defaultDate: "+3d" // + 3 days

You may also want to set your min and max dates so the date you want resides inside the date range.

 minDate: "01/01/1901",
 maxDate: "01/01/2099",
Joseph_J
  • 3,654
  • 2
  • 13
  • 22