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.
This question is related to
jquery
jquery-ui
datepicker
jquery-ui-datepicker
While the defaultDate does not set the widget. What is needed is something like:
$(".datepicker").datepicker({
showButtonPanel: true,
numberOfMonths: 2
});
$(".datepicker[value='']").datepicker("setDate", "-0d");
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')
i suspect that your default date format is different than the scripts default settigns. test your script with the 'dateformat' option
$( "#datepicker" ).datepicker({
dateFormat: 'dd-mm-yy'
});
instead of dd-mm-yy, your desired format
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() });
$( ".selector" ).datepicker({ defaultDate: null });
and return empty string from backend
Source: Stackoverflow.com