Search code examples
javascriptjquerytwitter-bootstrapdatetimepickerdatepicker

Boostrap datetimepicker: startDate: -Infinity not working


I'm working with bootstrap datetimepicker and I want to disabled the past days and I used

startDate: -Infinity

to set a minimum date but it doesn't work. And also i received an error in my console.

Uncaught TypeError: Cannot read property 'fn' of undefined

I also used the working code from this thread but still not working in my project. Here is my code:

   <div id="datetimepicker1" class="input-append date">
     <input data-format="dd/MM/yyyy" type="text"></input>
        <span class="add-on">
        <i data-time-icon="icon-time" data-date-icon="icon-calendar">
        </i>
        </span>
   </div>

My Javascript:

  $(function(){ 
        $('#datetimepicker1').datetimepicker({ 
        startDate: -Infinity , 
        pickTime: false
    });
  });

Regards!


Solution

  • Problem Fixed: I just change my script to:

       $(function(){ 
        var date = new Date();
        date.setDate(date.getDate());
    
      $('#datetimepicker1').datetimepicker({                            
            startDate: date,
            pickTime: false
      });
    
      });