2017-09-03 131 views
2

我想通過bootstrap-datetimepicker禁用時間選擇。如何禁用pickTime引導dateTimePicker

這是我的JavaScript:

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

我知道,有不同的DateTimePicker插件。我使用smalot/bootstrap-datetimepicker。即使我設置pickTimefalse,它不起作用?任何想法?

回答

1

您可以使用formatminViewoption,設置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">

+1

謝謝!!它工作正常! – Moh