How to set default time on bootstrap timepicker

How can I set the default time instead of the current time for this datetimepicker http://tarruda.imtqy.com/bootstrap-datetimepicker/ ?

+10
javascript jquery twitter-bootstrap timepicker
source share
3 answers

You can set the default time via JavaScript:

$('mySelector').timepicker({defaultTime: '10:45 PM'}); 

Or directly through the value attribute of your timepicker:

 <div class="bootstrap-timepicker"> <input id="timepicker" type="text" value="10:45 AM"/> </div> $('.myClass').timepicker({defaultTime: 'value'}); 

EDIT: was for the default timepicker parameter, my bad.

For your specific timepicker, it is possible to set the date-time as follows:

 var picker = $('#datetimepicker').data('datetimepicker'); picker.setDate(myDate); 
+12
source share

For bootstrap timepicker this will work:

 $('selector').val("time"); 
0
source share

From the documentation page. ,

setTime Set time manually

  $('#timepicker').timepicker('setTime', '12:45 AM'); 
0
source share

All Articles