views:

1794

answers:

1

The datepicker setDate method, as described here is not working as expected.

The datepicker is always taking browsers current date. But I want to
set the current date of my choice.

$(target).datepicker({ 
        dateFormat: $.datepicker.W3C, 
        closeText: 'X' 
}); 
//set the current date 
$(target).datepicker('setDate', currentDateObj); 
//checking the current date. 
alert($(target).datepicker('getDate'));

...where currentDateObj is a javascript date object containing date 1st August 2009.

When I alert the "getDate" it alerts 1st august 2009, but when I open the datepicker it displays the browsers current date ie. 31st august 2009 .

A: 

Have a try on this

$('.selector').datepicker('option', 'defaultDate', YourDateObj);

If this don't work, try to get the date object by js

YourDateObj = new Date ('year','month','day');
funktioneer
I tried this. Not working.I tried both the options 1. defaultDate 2. setDateBut the I realized that none of these are supposed to set the Today's date.
Varun