javascript 如何在 jQuery DateTimePicker 控件中获取小时和分钟选择器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32478572/
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
How to get hours and minutes selector in jQuery DateTimePicker control
提问by A.K
I have downloaded and tried the jQuery DatetimePicker control from http://plugins.jquery.com/datetimepicker/. This is v2.3.7.
我已经从http://plugins.jquery.com/datetimepicker/下载并尝试了 jQuery DatetimePicker 控件。这是 v2.3.7。
And in the download there is an image attached here which shows the selectors on both hours and minutes. But I haven't been able to find anything in the documentation on how to achieve that. Could someone please point out how to achieve this?
在下载中,这里附有一张图片,显示了小时和分钟的选择器。但是我在文档中找不到任何关于如何实现这一点的内容。有人可以指出如何实现这一目标吗?
$('#' + subgridid_complete).datetimepicker({
format: 'mm/dd/yy H:i',//'d.m.Y H:i',
//inline: true
mask:true,
});
This is what I get using the code above. Notice that the Hour and minute are not independently selectable.
这是我使用上面的代码得到的。请注意,小时和分钟不可独立选择。
Many thanks
非常感谢
回答by A.K
No example on the page shows a freely choosable time. You can use 'step'
to specify for example a 15 minute step in the time scroll-bar.
页面上没有示例显示可自由选择的时间。例如,您可以使用'step'
在时间滚动条中指定 15 分钟的步长。
You can also switch to the trentrichardson.com/examples/timepicker (a jquery-ui-addon). Here, the Time can be chosen, like in that example: trentrichardson.com/examples/timepicker
您还可以切换到 trentrichardson.com/examples/timepicker(一个 jquery-ui-addon)。在这里,可以选择时间,就像在那个例子中一样:trentrichardson.com/examples/timepicker
回答by Abin Abraham
If you want 15 minute intervals try:
如果您想要 15 分钟的间隔,请尝试:
step: 15,
回答by Nishith Kant Chaturvedi
From the documentation >> For time only
从文档>> 仅限时间
jQuery('#datetimepicker5').datetimepicker({
datepicker:false,
allowTimes:[
'12:00', '13:00', '15:00',
'17:00', '17:05', '17:20', '19:00', '20:00'
]
});
For datepicker with date and time use:
对于带有日期和时间的日期选择器,请使用:
jQuery('#datetimepicker4').datetimepicker({
format:'d.m.Y H:i'
});
datetimepicker4 and datetimepicker5 are textbox id on which you want to open calendar
datetimepicker4 和 datetimepicker5 是您要在其上打开日历的文本框 ID
回答by siva kumar
Have you seen this? http://xdsoft.net/jqplugins/datetimepicker/
你见过这个吗?http://xdsoft.net/jqplugins/datetimepicker/
This contains few examples on how to use the datetimepicker, and also use moment.js with this.
这包含了一些关于如何使用 datetimepicker 的示例,并且还使用了 moment.js。
回答by Thargor
I tried that before, too. No example on the documenation page shows a freely choosable time.
我以前也试过。文档页面上没有示例显示可自由选择的时间。
So I switched to jquerUI-timepicker. Here, the Time can be freely chosen. Many examples are provided.
所以我切换到jquerUI-timepicker。在这里,可以自由选择时间。提供了许多示例。