jQuery DateTimePicker AM/PM 下拉菜单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12974697/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DateTimePicker AM/PM Dropdown
提问by streetlight
I'm using (and loving) datetimepicker, the great add on to the jQuery UI Datepicker. However, I'm using the dropdown option (you can see all of them here -- http://trentrichardson.com/examples/timepicker/), and I want to have three dropdowns -- one for hours (1-12), minutes (00 to 60), and AM/PM.
我正在使用(并且喜欢)datetimepicker,这是 jQuery UI Datepicker 的一个很好的补充。但是,我正在使用下拉选项(您可以在此处查看所有选项 - http://trentrichardson.com/examples/timepicker/),并且我想要三个下拉列表 - 一个小时(1-12) 、分钟(00 到 60)和 AM/PM。
Right now, the hours field also has the am/pm, and I'm not sure how to add another dropdown to control the AM/PM.
现在,小时字段也有上午/下午,我不确定如何添加另一个下拉菜单来控制上午/下午。
Here's my initialization:
这是我的初始化:
$( ".datepicker" ).datetimepicker({
controlType: 'select',
timeFormat: "h:mm TT",
ampm: true
});
I feel like this may be a very easy problem, but I can't find any real documentation that alludes to how I do this. Please help!
我觉得这可能是一个非常简单的问题,但我找不到任何暗示我如何做到这一点的真实文档。请帮忙!
采纳答案by Peter Kigonya
Quick solution:
快速解决方案:
jquery-ui-timepicker-addon.js
jquery-ui-timepicker-addon.js
override or change "controlType: 'slider'," to "controlType: 'select',"
将“controlType: 'slider',”覆盖或更改为“controlType: 'select',”
回答by Cray Kao
Check this one and it works quiet well for me.
检查这个,它对我来说很安静。
http://xdsoft.net/jqplugins/datetimepicker/
http://xdsoft.net/jqplugins/datetimepicker/
The workable script:
可行的脚本:
$j('dDatetime').datetimepicker({
format: 'Y/m/d A g:i',
formatTime: 'A g:i',
});