Re: From float to hour and minutes

From: Date: Wed, 20 Jul 2005 23:12:04 +0000
Subject: Re: From float to hour and minutes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-219078@lists.php.net to get a copy of this message
I'm calculating the amount of time that an electric plant can operate with a certain amount of gas, let's say: A plant can work an hour with 10 galons, How long does it will work with 300 galons? hrs = (300 galons / 10 galons) = 30 (I could also have a float here!!!) Then, I have the time the plant was refilled, let's say 16:42, so I need to calculate the next hour the plant needs to be refilled. Like 16:42 hrs + 30 hrs How can I sum these two values? How can I convert the integer or float value 30 to a hour format?
With absolutely no testing and horrible variable names.... $x = "16:42"; $y = 30; list($h, $m) = explode(":", $x); $x1 = $h + $m/60; $total = $x1 + $y; $h = floor($total); $m = floor(($total - $h) * 60); $newtime = "$h:$m";

« previous php.general (#219078) next »