I am using a Jquery Datepicker in my project. The problem is that it is not loading the current date, but showing a date 1st January 2001 as default. Can you please let me know how the default date can be corrected so it will display the current date.
41
votes
Could you please provide some code to work with, if we cannot see what YOU are doing wrong, there is no way WE can help YOU!
- DonSeba
He makes a point, we're all making up JQuery syntax from scratch. If you include your code, we could come up with more relevant answers.
- ghayes
What datepicker? one of the numerous datepickers such as this one or the jQuery-UI datepicker? Note that jQuery-UI datepicker defaults to today so make sure your system date/time is correct.
- Salman A
I use the jQuery-UI datepicker
- MACMAN
@Gijo: by default the datepicker will default to the date present in the attached control or current date; unless your code tells to behave otherwise. Can you edit your question and post the code?
- Salman A
6 Answers
58
votes
Use the defaultDate option
$( ".selector" ).datepicker({ defaultDate: '01/01/01' });
If you change your date format, make sure to change the input into defaultDate (e.g. '01-01-2001')
53
votes
19
votes
Are u using this datepicker http://jqueryui.com/demos/datepicker/ ? if yes there are options to set the default Date.If you didn't change anything , by default it will show the current date.
any way this will gives current date
$( ".selector" ).datepicker({ defaultDate: new Date() });
11
votes
8
votes