Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 704
MACMAN Avatar asked Jul 11 '11 06:07

MACMAN


People also ask

How do I set the default date in datepicker?

Syntax: $(". selector"). datepicker( {defaultDate:"+6"} );

How do I change the default month in datepicker?

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

What is datepicker in jQuery?

The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.

What is minDate and maxDate in jQuery datepicker?

If you like to restrict access of users to select a date within a range then there is minDate and maxDate options are available in jQuery UI. Using this you can set the date range of the Datepicker. After defining these options the other days will be disabled which are not in a defined range.


2 Answers

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

like image 64
ghayes Avatar answered Sep 17 '22 18:09

ghayes


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

like image 45
Mujah Maskey Avatar answered Sep 17 '22 18:09

Mujah Maskey