APP+ Manual Appointments Duration Wrong

I wrote code to manually create an appointment, and it's worked great for over a year. For some reason, though, the duration setting isn't working quite right any more.

The appointment is created properly, but when an admin looks at the appointment in wp-admin, it shows the end time as only a few minutes after the appointment starts.

This is a problem because, quite often, the client has to re-assign the appointment to a different provider.

$duration = compduration($searchtime, $searchtime_end);
$duration = time_to_decimal($duration);

$searchparams = array(
     'user' => $familyID,
     'email' => $familyEMAIL,
     'name' => $familyNAME,
     'phone' => $familyPHONE,
     'address' => $familyADDRESS,
     'city' => $familyCITY,
     'worker' => $usertosearch,
     'price' => $price,
     'date' => $searchdate,
     'time' => date( 'H:i' , strtotime($searchtime) ),
     'note' => $formnote,
     'duration' => $duration,

compduration and timetodecimal are functions I found on stack overflow:

function compduration($timeA, $timeB) {
	$date['first'] = new DateTime($timeA);
	$date['second'] = new DateTime($timeB);
	if ($date['first'] > $date['second']) { $date['second']->add(new DateInterval('PT24H')); }
	$interval = $date['first']->diff($date['second']);
	return ($interval->format('%H:%i'));

function time_to_decimal($time) {
    $timeArr = explode(':', $time);
    $decTime = ($timeArr[0]) + ($timeArr[1]/60);
    return $decTime;

This was working just fine before the most recent updates.

Thank you for your help!

  • Rupok

    Hi jamesdonegan,

    So sorry to hear the inconvenience you are having. I'm pinging one of our SLS (Second Level Support) guys to check this. I believe, he will come up with his valuable feedback soon.

    Please keep in mind, our SLS people work round the clock and they have to deal with lots of critical issues and other things. So it may take a little while for them to check this and provide a feedback.

    I appreciate your patience.

    Have a nice day. Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.