Search code examples
bootstrap-datetimepickereonasdan-datetimepicker

is there any option in datetimepicker to active or highlight specifict days


I am using http://eonasdan.github.io/bootstrap-datetimepicker/ in my project for schedule doctors appointments.

I have completed everything, but one thing I did not find is that I want to highlight the days on which the doctor is available. I want those days to be active and the other days should be inactive or dim.

Thanks.


Solution

  • You can use disabledDates option to set disabled dates into the picker. In the following example, tomorrow and in three days are disabled:

    $('#datetimepicker1').datetimepicker({
      format: 'DD/MM/YYYY',
      disabledDates: [moment().add(1, 'd'), moment().add(3, 'd')]
    });
    <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet"/>
    <link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
    
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
    
    <div class='input-group date' id='datetimepicker1'>
      <input type='text' class="form-control" />
      <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
      </span>
    </div>