开发者

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜