我想用bootstrap-datetimepicker禁用时间选择。
这是我的JavaScript:
$('.dateTimePicker2').datetimepicker({
language: "fr",
pickTime: false,
});
我知道有不同的datetimepicker插件。我使用了smalot / bootstrap-datetimepicker。即使我将pickTime
设置为false
,它也不起作用?有什么想法吗?
答案 0 :(得分:1)
您可以使用format
和minView
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;