如何禁用pickTime bootstrap dateTimePicker

时间:2017-09-03 21:45:13

标签: bootstrap-datetimepicker smalot-datetimepicker

我想用bootstrap-datetimepicker禁用时间选择。

这是我的JavaScript:

$('.dateTimePicker2').datetimepicker({
    language: "fr",
    pickTime: false,
});

我知道有不同的datetimepicker插件。我使用了smalot / bootstrap-datetimepicker。即使我将pickTime设置为false,它也不起作用?有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您可以使用formatminView option,设置format: "yyyy-mm-dd"minView: "month"format选项确定要在输入中显示的格式,而minView选项是datetimepicker应显示的最低视图

这是一份工作样本:



$('.dateTimePicker2').datetimepicker({
    format: "yyyy-mm-dd",
    minView: "month",
    language: "fr"
});

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/smalot-bootstrap-datetimepicker/2.4.4/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/smalot-bootstrap-datetimepicker/2.4.4/js/bootstrap-datetimepicker.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/smalot-bootstrap-datetimepicker/2.4.4/js/locales/bootstrap-datetimepicker.fr.js"></script>

<input size="16" type="text" readonly class="dateTimePicker2">
&#13;
&#13;
&#13;