This question already has an answer here:
I just want today's date to be the default value in the input that is using jQuery UI's datepicker
:
<input id="mydate" type="text" />
I tried the below code but it didn't work:
var currentDate = new Date();
$("#mydate").datepicker("setDate",currentDate);
You need to make the call to setDate separately from the initialization call. So to create the datepicker and set the date in one go:
Why it is like this I do not know. If anyone did, that would be interesting information.
try this:
This one work for me , first you bind datepicker to text-box and in next line set (today as default date) the date to it
You have to initialize the datepicker before calling a datepicker method
Here is a
Working JSFiddle.
P.S: This assumes that you have the correct date set in your computer
This worked for me and also localised it:
Try this: