Javascript 如何在 Bootstrap DateTimePicker 中禁用时间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28449801/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable time in Bootstrap DateTimePicker?
提问by Emre BEGEN
I wanna use bootstrap datetimepicker without select time but it is not working. I gave false value to the pickTime parameter but it is still not working. But Format and language parameters is working.
我想在没有选择时间的情况下使用 bootstrap datetimepicker,但它不起作用。我给 pickTime 参数提供了 false 值,但它仍然无法正常工作。但是格式和语言参数正在起作用。
Here is the code! How can i fix this?
这是代码!我怎样才能解决这个问题?
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker({
format: "dd MM yyyy",
pickTime: false,
autoclose: true,
todayBtn: true,
language: 'tr',
pickerPosition: "bottom-right"
});
});
</script>
<div class='input-group date' id='datetimepicker1'>
<span class="input-group-addon">Birtdate</span>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"> </span>
</span>
</div>
回答by Nguyen Linh
There are many datetimepicker plugin, so you need to details what plugin you used. If you use the plugin from http://eonasdan.github.io/bootstrap-datetimepicker/. I think, you may use wrong its option : read more at http://eonasdan.github.io/bootstrap-datetimepicker/Options/. Here I removed almost, and just keep one:
有很多 datetimepicker 插件,因此您需要详细说明您使用的插件。如果您使用来自http://eonasdan.github.io/bootstrap-datetimepicker/的插件。我认为,您可能会使用错误的选项:在http://eonasdan.github.io/bootstrap-datetimepicker/Options/阅读更多内容。在这里我几乎删除了,只保留一个:
$('#datetimepicker1').datetimepicker({
format: "dd MM yyyy"
});
回答by pramod kadam
try this remove pickTime Option and use minview : 2
试试这个删除pickTime选项并使用minview:2
$(function() {
$('#datetimepicker4').datetimepicker({
minView : 2
});
});
回答by Shakthi
Try the below code, which will show only the date view, when the calendar is pulled down.
试试下面的代码,当日历被下拉时,它只会显示日期视图。
$(function () {
$('#datetimepicker1').datetimepicker({
format: 'yyyy-mm-dd',
startView: 'month',
minView: 'month',
autoclose: true
});
});
回答by Denise
I found this website online it disables the time picker
我在网上找到了这个网站,它禁用了时间选择器
http://tarruda.github.io/bootstrap-datetimepicker/
<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>

