Ok, I have a variable ($incubation) set as 04:00:00.
Then I have another variable ($starttime) set to the current time.
Both are printing out fine.
But I'm trying to get an $endtime from adding the incubation time to the start time.

$incubation = $row['incubation']; //IM GRABBING THIS TIME FROM THE DATABASE. It prints 04:00:00
	$starttime = date("H:i:s"); //prints 16:23:39
	$endtime = date("H:i:s", $starttime+$incubation);  //prints 20:00:00 when it's suppose to print 20:23:39

Have a look at the funktion "mktime()" on php.net. It is a very poweful yet simple function for date and time calculations.

Member Avatar

Your method will work if you transform the hours into seconds. I assume your incubation is a time interval (4 hrs) as opposed to a set time (4 am).

function convTime($dbtime){
    list($h, $m, $s) = explode(':', $dbtime);
    return ($h * 3600 ) + ($m * 60 ) + $s;

$incubation = convTime($row['incubation']);
$starttime = date("H:i:s"); 
$endtime = date("H:i:s", $starttime+$incubation);

I got a version of this function from somewhere else some time ago. Can't remember where.