我有这个DateTimePicker:

我只需要编辑时间,所以我只需要显示以下内容:

代码:
setDateTime: function(index){
$('#date_time_'+index+'_id').datetimepicker({
showClose:true,
format: 'DD/MM/YYYY HH:mm',
ignoreReadonly: true
});
},因此,显示日期和时间的输入很好,但我只需要编辑时间
我正在使用这个:bootstrap-datetimepicker
但我不知道使用什么选项。对不起,我的英语。
发布于 2015-11-04 21:41:45
不幸的是,我认为如果不更新bootstrap datetimepicker lib,您将不得不使用alternative。因为这个库不仅仅是为time picker准备的。
请使用类似于此的内容。相同的格式,但有更多的选择:http://tarruda.github.io/bootstrap-datetimepicker/
然后你就可以用这个设置你想要的东西
$('#date_time_'+index+'_id').datetimepicker({
pickDate: false
});发布于 2015-11-04 21:50:09
只需在format中指定时间,如下所示:
https://jsfiddle.net/9jkxL4su/
$('#datetimepicker1').datetimepicker({
format: 'LT'
});编辑:
要显示日历(切换)图标,您需要在显示选取器时触发切换-单击:
https://jsfiddle.net/pv8Lhy9t/
$('#datetimepicker1').datetimepicker({
allowInputToggle: true,
showClose: true
});
$('#datetimepicker1').on("dp.show", function(){
var toggle = $(this).find('a[data-action="togglePicker"]');
if(toggle.length > 0) toggle.click();
// To hide the toggle back to calendar button, uncomment line below
// $(this).find('a[data-action="togglePicker"]').hide();
});注:您可以删除用户切换回以编辑日期的功能。只需取消注释最后一行,如上面的代码所示。
READONLY:要限制手动编辑日期的能力,只需为输入字段提供一个只读属性,并在选择器中将ignoreReadonly属性设置为true:https://jsfiddle.net/xgm99t5o/
发布于 2015-11-04 21:40:05
组件的名称是什么?
也许你可以使用: pickDate: false;或者只使用格式:'HH:mm',
在这个组件中,它看起来像:https://tarruda.github.io/bootstrap-datetimepicker/
https://stackoverflow.com/questions/33523214
复制相似问题