开发者

Is there a JavaScript way to set the time for this jQuery timepicker plugin?

I would like to set the current date/time to populate automatically into the input textbox according to the same format used by this timepicker plugin:

http://trentrichardson.com/examples/timepicker/

The plugin assumes that you want the input text field to appear blank until the user interacts with it.

$('#example2').datetimepicker({
    ampm: true
});

But I want the input text field to already contain the current date and time:

05/16/2011 04:00 am

The only way I can see to do this at the moment is using my server-side scripting language.

But ideally there should be a way to do thi开发者_Python百科s with JavaScript or jQuery?


In the link you provided, it shows you how to specify the time:

$('#example7').datetimepicker({
    hour: 13,
    minute: 15
});

A quick way would be to set the value of the text box within the HTML markup, e.g.

<input type="text" id="example7" value="05/16/2011 04:00" />

Or it could be done with JQuery:

$('#example7').val("05/16/2011 04:00");


Use

$('#yourcontrol').datetimepicker('setDate', new Date());

to set the control with current date and time.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜