如何在PHP中添加时间值?

I was trying to do start_time+appt_duration=end_time; start_time is e:g: 08:00:00 duration e:g: 01:30:00

but endtime is coming with : 00:54:08

All the attributes are configured 'time' in database.

Code:

     $time= $model->start_time;

     $duration=$model->appt_duration;

     $duration_array = explode(':', $duration);

     $length = ((int)$duration_array[0] * 3600) + ((int)$duration_array[1] * 60) + (int)$duration_array[2];
     $target = $length + $time;

     $model->end_time= $target;

Try this :

    $length = ((int)$duration_array[0] * 3600) + ((int)$duration_array[1] * 60)
    + (int)$duration_array[2];
    $model->end_time = date("H:i:s",  
            strtotime("+".$length." seconds",strtotime($model->start_time))
            );

I prefere using \DateTime object, from http://www.php.net/manual/en/datetime.add.php:

$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P10D'));
echo $date->format('Y-m-d'), PHP_EOL;

See also \DateTime::createFromFormat() - http://www.php.net/manual/de/datetime.createfromformat.php