在 Bootstrap Datetimepicker 中禁用分钟选择
Disable minutes selection in Bootstrap Datetimepicker
我不想 datetimepicker 只显示四舍五入的小时数并禁用分钟选择。因此用户将只能选择小时数,例如 02:00。但是我无法完成这个简单的任务。这是我的代码(在 Laravel 视图中):
$("#date_from").datetimepicker({
format: 'yyyy-mm-dd hh:00',
startDate: "{{date('Y-m-d')}}",
minuteStepping: 60,
autoclose: true }).on('hide', function(e) {
$("#date_to").datetimepicker(
"setStartDate", new Date($('#date_from').val())
)....
我试过 steps: 60
、stepping:60
、minView: 1
等。
我仍然得到这个
查看选项 viewMode 和格式
https://eonasdan.github.io/bootstrap-datetimepicker/Options/
尝试使用 step:60 而不是 steps
请也检查此 link :
这里有一个例子,我想它会对你有所帮助。
jsfiddle.net/tmk0293z/7/
有changedate事件绑定一个函数,改变其他字段的另一个开始日期。
谢谢,
Nishit Zinzuvadiya
这是实际的代码
(HTML):
<div class="input-append date form_datetime" id="first">
<input type="text" value="" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
<div class="input-append date form_datetime" id="second">
<input type="text" value="" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
<span id="selected"></span>
JS:
$(".form_datetime").datetimepicker({
format: "dd MM yyyy - hh:ii",
minView:1,
autoclose:true
});
$("#first").datetimepicker().on("changeDate", function(e){
var first = new Date(e.date.setMinutes(0));
first.setHours(first.getHours()+first.getTimezoneOffset()/60); //timezone correction
$("#second").datetimepicker('setStartDate', first);
//other = $("#first").find("input").val();
//$("#second").datetimepicker('setStartDate', other); //works also
});
我不想 datetimepicker 只显示四舍五入的小时数并禁用分钟选择。因此用户将只能选择小时数,例如 02:00。但是我无法完成这个简单的任务。这是我的代码(在 Laravel 视图中):
$("#date_from").datetimepicker({
format: 'yyyy-mm-dd hh:00',
startDate: "{{date('Y-m-d')}}",
minuteStepping: 60,
autoclose: true }).on('hide', function(e) {
$("#date_to").datetimepicker(
"setStartDate", new Date($('#date_from').val())
)....
我试过 steps: 60
、stepping:60
、minView: 1
等。
我仍然得到这个
查看选项 viewMode 和格式 https://eonasdan.github.io/bootstrap-datetimepicker/Options/
尝试使用 step:60 而不是 steps
请也检查此 link :
这里有一个例子,我想它会对你有所帮助。
jsfiddle.net/tmk0293z/7/
有changedate事件绑定一个函数,改变其他字段的另一个开始日期。
谢谢, Nishit Zinzuvadiya
这是实际的代码 (HTML):
<div class="input-append date form_datetime" id="first">
<input type="text" value="" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
<div class="input-append date form_datetime" id="second">
<input type="text" value="" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
<span id="selected"></span>
JS:
$(".form_datetime").datetimepicker({
format: "dd MM yyyy - hh:ii",
minView:1,
autoclose:true
});
$("#first").datetimepicker().on("changeDate", function(e){
var first = new Date(e.date.setMinutes(0));
first.setHours(first.getHours()+first.getTimezoneOffset()/60); //timezone correction
$("#second").datetimepicker('setStartDate', first);
//other = $("#first").find("input").val();
//$("#second").datetimepicker('setStartDate', other); //works also
});