Skip to content Skip to sidebar Skip to footer

Disable Future Dates In Bootstrap 3 Datetimepicker

I'm using Bootstrap 3 Datetimepicker and I need to disable all my future dates, I know it has it's own disabledDates function but I tried so many times and it's still not working.

Solution 1:

You should use maxDate option instead of disabledDates.

Here a working example:

$('#data_move').datetimepicker({
  locale: 'pt-br',
  maxDate: moment()
});
<linkhref="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" /><linkhref="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css" /><scriptsrc="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script><scriptsrc="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/locale/pt-br.js"></script><scriptsrc="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script><scriptsrc="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script><divclass='input-group date'id='data_move'><inputtype='text'class="form-control" /><spanclass="input-group-addon"><spanclass="glyphicon glyphicon-calendar"></span></span></div>

Solution 2:

 $('#data_move').datetimepicker({               
            maxDate: newDate
        });

Try this it will work.

Post a Comment for "Disable Future Dates In Bootstrap 3 Datetimepicker"