Initial restart time of the Bootstrap Timepicker

How to dynamically change initialization time in Bootprap Timepicker?

http://jdewit.github.com/bootstrap-timepicker/

Thanks for any help!

+4
source share
4 answers

If you do not want to use the current time (which is the default), you can either use the parameters during initialization:

 $('someSelector').timepicker({defaultTime: '11:42 PM'}); 

Or you can use the value attribute of the input (which simplifies initialization for multiple timers):

 <input type="text" class="myClass input-small" value="12:42 PM"> 
 $('.myClass').timepicker({defaultTime: 'value'}); 

Demo (jsfiddle)

+9
source

I am the author of timepicker.

The value parameter for the default time is out of date. You have many ways to set a default time for a specific value.

set value attribute

 <div class="bootstrap-timepicker"> <input id="timepicker" type="text" value="12:45 AM"/> </div> 

or set the data attribute to override the configuration option

 <div class="bootstrap-timepicker"> <input id="timepicker" type="text" data-default-value="12:45 AM"/> </div> 

or by init

 $('#timepicker').timepicker({ defaultValue: '12:45 AM' }); 

or call setTime method

 $('#timepicker').timepicker(); $('#timepicker').timepicker('setTime', '12:45'); 

Just open the problem on github if you have any problems!

+3
source

Decision:

 var time = '@Model.MarketTime.ToString("h:mm tt")' $('#timepicker-default').timepicker('setTime', time); 
+1
source
 <div class="input-append bootstrap-timepicker span8"><input id="timeinput" type="text" class="timepicker-2 input-small" value="current"><span class="add-on"><i class="icon-time"></i></span></div> 

This works for me ...

0
source

Source: https://habr.com/ru/post/1435914/


All Articles