Do you want to change #onselectTarget
when #onselectExample
changes?
It can be achieved as follows:
$('#onselectExample').timepicker({
onSelect: function(selectedDateTime){
$('#onselectTarget').text(selectedDateTime);
}
});
And in case you want to add 30 minutes to the selected Time you could write an extra fundtion:
$(function(){
$('#onselectExample').timepicker({
onSelect: function(selectedDateTime){
console.log(selectedDateTime);
$('#onselectTarget').text(add30Min(selectedDateTime));
}
});
});
function add30Min(oldTime){
var time = oldTime.split(":"); //split hours an minutes
var hours = time[0]; // get hours
var minutes = time[1]; // get minutes
if (+minutes >= 30){ // when minutes over 30
hours = (+hours+1)%24; // add an hour and convert 24 to 0
}
minutes = (+minutes + 30)%60; // add 30 minutes and convert 61 to 1
return $.datepicker.formatTime('hh:mm',{ // use formatTime to return formatted Time
'hour':hours,
'minute':minutes
});
}