I am using jquery timepicker
I need set the initial time.
let pickip_time = "08:31"
if(pickip_time){
pickup_array = pickip_time.split(":");
$('#pickupTime').timepicker({timeFormat:'HH:mm TT',hour:pickup_array[0],minute:pickup_array[1]});
//$('#pickupTime').val(pickip_time);
} else {
$('#pickupTime').timepicker({timeFormat:'HH:mm TT'});
}
Above code does not work. I even tried with below code it is not working
$('#pickupTime').timepicker({timeFormat:'HH:mm TT',startTime:pickip_time});
2
Answers
The
startTime
property is not intended to set initial value, as documentation says it is:AFAIK the correct way to set initial time on this object is after init, with
setTime
action:Praveen – piece of code you’ve shared seems to be working fine, I am using the same piece of code which you have shared in this snippet and it works fine. Please try.
Please check if you are using correct version of jQuery libraries or not or you might be facing a conflict. If you could share a screenshot of error you’re seeing in console then that would help.
I hope you get the solution.