how do i assign a date to jquery ui datepicker?
I am trying to assign a date into a jquery ui datepicker. I have the date coming like Sat Jan 01 00:00:00 GMT 2011 . How can i assign this value so the datepicker.
Thanks P开发者_如何学Gorady
It looks like regular JavaScript's Date
object already accepts such format, so you can perfectly do this:
var myDate = new Date("Sat Jan 01 00:00:00 GMT 2011");
Now, call datepicker.setDate() and you're done:
myDatePicker.datepicker("setDate", myDate);
The datepicker would set the date to the value in the box.
if the box is blank then the value will aways default to the value you mention.
There is a CurrentText Option but I dont know what that does.
Maybe DefaultDate would be the better option?
$(".datepicker").datepicker({ defaultDate: new Date() });
精彩评论