Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing time in php

Status
Not open for further replies.

funkygeezer1975

Technical User
Dec 14, 2004
22
GB
I am trying to now work out total time but it does not pass the total time in time foramat see code below how do i get the correct time returned??

$sql = "SELECT * FROM delivery WHERE Check_Employee_id ='$_POST[checkemployee]' AND Check_Date = '$date'";
$result = mysql_query($sql,$conn);
while ($newArray = mysql_fetch_array($result)) {

$id = $newArray['DeliveryId'];
$Supplier = $newArray['Supplier'];
$Lines = $newArray['Num_of_lines'];
$stime = $newArray['Check_Start_Time'];
$ftime = $newArray['Check_Finish_Time'];
$tottime = $ftime - $stime;
$num_lines = mysql_num_rows($result);
$counter = $counter + $Lines;
$timecounter= $timecounter + $tottime;

echo "
<tr><td><center>$id</center></td><td><center>$Supplier</center></td><td><center>$Lines</center> </td><td><center><b>$counter</b></center></td><td><center>$stime</center></td><td><center>$ftime</center></td></tr>";

}
 
Craked it took me a while but done it now i have broken $stime and $ftime in to shour and $smin i can get an accurate display see code below

$id = $newArray['DeliveryId'];
$Supplier = $newArray['Supplier'];
$Lines = $newArray['Num_of_lines'];
$stime = $newArray['Check_Start_Time'];
$ftime = $newArray['Check_Finish_Time'];
$counter = $counter + $Lines;
$sh= ''.substr($stime,0,2);
$sm= ''.substr($stime,3,2);
$fh= ''.substr($ftime,0,2);
$fm= ''.substr($ftime,3,2);
$thour= $fh - $sh;
$tmin= $fm - $sm;
if($tmin<10){
$ttime= "$thour:0$tmin";
} else
{
$ttime= "$thour:$tmin";
}

echo "
<tr><td><center>$id</center></td><td><center>$Supplier</center></td><td><center>$Lines</center> </td><td><center>$stime</center></td><td><center>$ftime</center></td><td><center><b>$ttime</b><center></td></tr>";

}


All by myself well chuffed to start answering my own questions
Hope this helps anyone in the same situation as myself
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top