Disable time in bootstrap date time picker

前端 未结 20 1388
夕颜
夕颜 2021-01-30 07:56

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-datetimepic

相关标签:
20条回答
  • 2021-01-30 08:41
    <script type="text/javascript">
            $(function () {
                      $('#datepicker').datetimepicker({
                         format: 'YYYY/MM/DD'
                   });
                });
    </script>
    
    0 讨论(0)
  • 2021-01-30 08:43

    I spent some time trying to figure this out due to the update with DateTimePicker. You would enter in a format based off of moment.js documentation. You can use what other answers showed:

    $('#datetimepicker').datetimepicker({ format: 'DD/MM/YYYY' });
    

    Or you can use some of the localized formats moment.js provides to do just a date, such as:

    $('#datetimepicker').datetimepicker({locale: 'fr', format: 'L' });
    

    Using this, you are able to display only a time (LT) or date (L) based on locale. The documentation for datetimepicker wasn't clear to me that it automatically adapts to the input provided (date or only time) via moment.js format. Hope this helps for those still looking.

    0 讨论(0)
提交回复
热议问题