Ok so this issue has been stumping me for awhile. I have a website where a user inputs 2 times and dates i.e. 0100 and 0400 hose get assigned to a variable and are later pulled from the database to get the total time.
Currently I have the code below which will add the 2 times but what I am experiencing right now is the times add fine until the 12th hour at which it resets to 0. I have mysql database as a time data type and if I manually plug in lets say 45 hours it will display that amount but as soon as my function adds time to it, it resets to 0. Any advice would be greatly appreciated. The function I am using isnt mine and was a found function, I am just having ahard time wrapping my thoughts around this one. Maybe cause ive looked at it too long. :) Thank You
function AddPlayTime ($oldPlayTime, $PlayTimeToAdd) {
$pieces = split(':', $oldPlayTime);
$hours=$pieces[0];
$hours=str_replace("00","12",$hours);
$minutes=$pieces[1];
$seconds=$pieces[2];
$oldPlayTime=$hours.":".$minutes.":".$seconds;
$pieces = split(':', $PlayTimeToAdd);
$hours=$pieces[0];
$hours=str_replace("00","12",$hours);
$minutes=$pieces[1];
$seconds=$pieces[2];
$str = $str.$minutes." minute ".$seconds." second" ;
$str = "01/01/2000 ".$oldPlayTime." am + ".$hours." hour ".$minutes." minute ".$seconds." second" ;
if (($timestamp = strtotime($str)) === false) {
return false;
} else {
$sum=date('h:i:s', $timestamp);
$pieces = split(':', $sum);
$hours=$pieces[0];
$hours=str_replace("12","00",$hours);
$minutes=$pieces[1];
$seconds=$pieces[2];
$sum=$hours.":".$minutes.":".$seconds;
return $sum;
}
}
$firstTime=$data3[flightHours];
$secondTime=mysql_real_escape_string($_GET['flightTime']);
$sum=AddPlayTime($data3[flightHours], mysql_real_escape_string($_GET['flightTime']));
$sumUnit=AddPlayTime($data4[hours], mysql_real_escape_string($_GET['flightTime']));
$sumWing=AddPlayTime($rowwg[hours], mysql_real_escape_string($_GET['flightTime']));
$sumSq=AddPlayTime($rowsq[hours], mysql_real_escape_string($_GET['flightTime']));