MACMAN
MACMAN

Reputation: 1971

Jquery Date picker Default Date

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.

Upvotes: 42

Views: 244875

Answers (6)

Mujah Maskey
Mujah Maskey

Reputation: 8804

interesting, datepicker default date is current date as I found,

but you can set date by

$("#yourinput").datepicker( "setDate" , "7/11/2011" );

don't forget to check you system date :)

Upvotes: 56

Vazgen Torosyan
Vazgen Torosyan

Reputation: 1295

$( ".selector" ).datepicker({ defaultDate: null });

and return empty string from backend

Upvotes: 0

hayesgm
hayesgm

Reputation: 9096

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')

Upvotes: 60

James A Mohler
James A Mohler

Reputation: 11120

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"); 

Upvotes: 11

Sarath
Sarath

Reputation: 9146

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() });

Upvotes: 20

andrew
andrew

Reputation: 2098

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

Upvotes: 8

Related Questions