如何在bootstrap-dateTimePicker中隐藏选择日期?

时间:2015-11-04 13:30:52

标签: javascript jquery bootstrap-datetimepicker

我有这个DateTimePicker:

enter image description here

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

enter image description here

代码:

setDateTime: function(index){
    $('#date_time_'+index+'_id').datetimepicker({
        showClose:true,
        format: 'DD/MM/YYYY HH:mm',
        ignoreReadonly: true
    });
},

因此显示日期和时间的输入很好,但我只需要编辑时间

我用这个: bootstrap-datetimepicker

但我不知道使用什么选项。 对不起我的英文。

3 个答案:

答案 0 :(得分:0)

不幸的是,我认为如果不更新bootstrap datetimepicker lib,你将不得不使用替代方案。因为这个库不适合时间选择器。

请使用类似的东西。格式相同,但有更多选项: http://tarruda.github.io/bootstrap-datetimepicker/

然后你可以用这个

设置你想要的东西
preg_match('^\[caption(.*?)\]^', $content, $matches);

答案 1 :(得分:0)

只需在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:要限制手动编辑日期的功能,只需为输入字段指定readonly属性,并在选择器中将ignoreReadonly属性设置为true:https://jsfiddle.net/xgm99t5o/

答案 2 :(得分:-1)

组件的名称是什么?

也许您可以使用以下内容: pickDate:false; 或者只是 格式:'HH:mm',

在此组件中,它看起来像:https://tarruda.github.io/bootstrap-datetimepicker/