How to restrict the bootstrap timepicker min-time and max-time?

若如初见. 提交于 2019-12-04 10:02:58
  1. use event changeTime,
  2. check the current time,
  3. if time is less set minimum

http://jsfiddle.net/j3kf2p2e/

$('#timepicker').timepicker({
        showMeridian: true,        
        minuteStep: 1,
        showInputs: true,        
}).on('changeTime.timepicker', function(e) {    
    var h= e.time.hours;
    var m= e.time.minutes;
    var mer= e.time.meridian;
    //convert hours into minutes
    m+=h*60;
    //10:15 = 10h*60m + 15m = 615 min
    if(mer=='AM' && m<615)
        $('#timepicker').timepicker('setTime', '10:15 AM');
  });

You can use the following:eg if mindate is at 8.00 and maxdate is at 2300hrs

    minDate: moment({h:8}),
    maxDate: moment({h:23}),

that is...

$('#time').bootstrapMaterialDatePicker({
    format: 'HH:mm',
    minDate: moment({h:8}),
    maxDate: moment({h:23}),
    clearButton: true,
    date: false
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!