note 9040 deleted from function.date by jimw

From: Date: Fri, 02 Nov 2001 00:43:02 +0000
Subject: note 9040 deleted from function.date by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20059@lists.php.net to get a copy of this message
Well, I was having a really hard time trying to maintain human time readability in a MySQL db. The time spent working on an issue is entered as "hours:minutes", i.e, 1:37. But when trying to manipulate the column data in a total of srts, I was running into the problem of having total times that looked illogical like "12:154". So I have wrote this code to make it look normal to us human folk again. Hope this helps. $result3=mysql_query ("SELECT timespent FROM followinfo WHERE ticketnum=$ticketnum", $db); while($row3=mysql_fetch_array($result3)) { $g=explode(":",$row3[timespent]); // Separate human looking time into hours and minutes print "<p>"; $hrttl=$hrttl+$g[0]; // Add hour column $minttl=$minttl+$g[1]; // Add minutes column $j=($minttl-60); // Subtract 60 minutes from minute total if($j>0) // If minute minute total - 60 is positive { $hrttl=$hrttl+1; // Add 1 hour to hour column $minttl=$j; // and reset change minute total value to whatever minus 60 } }

« previous php.notes (#20059) next »