How to set default time on Bootstrap timepicker
Asked Answered
A

5

11

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

Abreu answered 27/10, 2014 at 9:40 Comment(0)
S
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);
Stallion answered 27/10, 2014 at 9:45 Comment(0)
T
5

From the documentation page..

setTime Set the time manually

  $('#timepicker').timepicker('setTime', '12:45 AM');
Tidemark answered 21/5, 2019 at 8:53 Comment(0)
R
0

For bootstrap timepicker this would work :

$('selector').val("time");
Riddell answered 15/4, 2017 at 9:16 Comment(0)
K
0

I Think You Should try this. It work for me

$('.time').timepicker({
    minuteStep: 1,
    defaultTime: null
});
Ketch answered 16/11, 2019 at 11:34 Comment(0)
F
0

Set value before to initialize timepicker

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

Might be working this way

Finegan answered 8/2, 2021 at 5:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.