How to set default time on Bootstrap timepicker

51,016

Solution 1

You can set the default time via JavaScript :

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

Or directly via 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 of boostrap, my bad.

For your specific timepicker, it seems possible to set the datetime like this :

var picker = $('#datetimepicker').data('datetimepicker');
picker.setDate(myDate);

Solution 2

From the documentation page..

setTime Set the time manually

  $('#timepicker').timepicker('setTime', '12:45 AM');
Share:
51,016
iamspauljamez
Author by

iamspauljamez

Self-centered bastard developer based in the country called 'Philippines'. :)

Updated on February 08, 2021

Comments