11

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

Veve
  • 6,643
  • 5
  • 39
  • 58
iamspauljamez
  • 287
  • 1
  • 3
  • 14

5 Answers5

15

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);
Diogo Cid
  • 3,764
  • 1
  • 20
  • 25
Veve
  • 6,643
  • 5
  • 39
  • 58
5

From the documentation page..

setTime Set the time manually

  $('#timepicker').timepicker('setTime', '12:45 AM');
successtar
  • 319
  • 3
  • 4
0

For bootstrap timepicker this would work :

$('selector').val("time");
Veve
  • 6,643
  • 5
  • 39
  • 58
Arindam Dawn
  • 1,769
  • 2
  • 18
  • 35
0

I Think You Should try this. It work for me

$('.time').timepicker({
    minuteStep: 1,
    defaultTime: null
});
hivert
  • 10,579
  • 3
  • 31
  • 56
0

Set value before to initialize timepicker

$('#start_time').val('12:00 AM');
$('#start_time').timepicker(); 

Might be working this way

Mukesh Kumar
  • 57
  • 2
  • 7