在引导日期时间选择器中禁用时间 [英] Disable time in bootstrap date time picker

查看:111
本文介绍了在引导日期时间选择器中禁用时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的web应用程序中使用引导日期时间选择器,使用PHP / HTML5和JavaScript制作。我目前使用的是:
http://tarruda.github.io/bootstrap-datetimepicker/



当我没有时间使用控件时,它不起作用。它只显示一个空白的文本框。



我只想从日期时间选择器中删除时间。有没有解决方案?

 < div class =well> 
< div id =datetimepicker4class =input-append>
< input data-format =yyyy-MM-ddtype =text>< / input>
< span class =add-on>
< / span>
< / div>
< / div>
< script type =text / javascript>
$(function(){
$('#datetimepicker4')。datetimepicker({pickTime:false});
});
< / script>


解决方案

检查下面的代码片段b

 < div class =container> 
< div class =row>
< div class ='col-sm-6'>
< div class =form-group>
< div class ='input-group date'id ='datetimepicker4'>
< input type ='text'class =form-control/>
< span class =input-group-addon>< span class =glyphicon glyphicon-time>< / span>
< / span>
< / div>
< / div>
< / div>
< script type =text / javascript>
$(函数(){
// Bootstrap DateTimePicker v4
$('#datetimepicker4')。datetimepicker({
格式:'DD / MM / YYYY'
});
});
< / script>
< / div>



您可以参考 http://eonasdan.github.io/bootstrap-datetimepicker/ 详细了解文档和其他功能。
这应该是有效的。


支持i18n的更新



使用本地化的moment.js格式:
$ b


  • L 仅限日期

  • LT 仅限时间

  • L LT 日期和时间



请参阅moment.js文档中的其他本地化格式( https://momentjs.com/docs/#/displaying/format/


I am using bootstrap date time picker in my web application, made in PHP/HTML5 and JavaScript. I am currently using one from here: http://tarruda.github.io/bootstrap-datetimepicker/

When I am using the control without time, it doesn't work. It just shows a blank text box.

I just want to remove time from date time picker. Is there any solution for this?

<div class="well">
    <div id="datetimepicker4" class="input-append"> 
        <input data-format="yyyy-MM-dd" type="text"></input> 
        <span class="add-on"> 
            <i data-time-icon="icon-time" data-date-icon="icon-calendar"> </i> 
        </span> 
    </div> 
</div> 
<script type="text/javascript"> 
    $(function() { 
        $('#datetimepicker4').datetimepicker({ pickTime: false }); 
    }); 
</script>

解决方案

Check the below snippet

<div class="container">
<div class="row">
    <div class='col-sm-6'>
        <div class="form-group">
            <div class='input-group date' id='datetimepicker4'>
                <input type='text' class="form-control" />
                <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span>
                </span>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function() {              
           // Bootstrap DateTimePicker v4
           $('#datetimepicker4').datetimepicker({
                 format: 'DD/MM/YYYY'
           });
        });      
    </script>
</div>

You can refer http://eonasdan.github.io/bootstrap-datetimepicker/ for documentation and other functions in detail. This should work.

Update to support i18n

Use localized formats of moment.js:

  • L for date only
  • LT for time only
  • L LT for date and time

See other localized formats in the moment.js documentation (https://momentjs.com/docs/#/displaying/format/)

这篇关于在引导日期时间选择器中禁用时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆