Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a default date in Eonasdan Bootstrap datepicker

I use http://eonasdan.github.io/bootstrap-datetimepicker/ for Calendar functionality

Here is the html

         <div class="form-group" id="div_mydatecontainer">
             <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>
         </div> 

construct

$('#datetimepicker1').datetimepicker({
     format: 'l',
     locale:'en-gb'
});

How can I display a default date which is 20 days from current date?

like image 790
user4826347 Avatar asked Apr 10 '26 04:04

user4826347


1 Answers

use defaultDate and moment.js (which I believe is required for that plugin anyway)

$('#datetimepicker1').datetimepicker({
     format: 'l',
     locale:'en-gb',
     defaultDate: moment().add(20, 'days')
});
like image 52
Mike Avatar answered Apr 12 '26 17:04

Mike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!