Adding time in php

Adding time in php

am 04.03.2006 07:38:45 von Allan

Hi All

I have two tables with columns of times that it took to perform tasks eg:

8:40
6:50
8:30
10:55
---------
34:55 total time taken to complete the tasks in hours and minutes

I am able to add the times with sql however I need to add the totals to cone
up with a grand total and because of the makeup of the tables I cant use
sql. I am there for going to have to use php code and this is where the
problem comes in because in sql there is SEC_TO_TIME and TIME_TO_SEC
functions that allow easy addition of the times but I cant find an
equivalent in php. Does any one know of a way that I can add to times
together in php.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Adding time in php

am 05.03.2006 03:18:15 von jusa_98

--0-1118794499-1141525095=:5417
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hi,

All you need to do is run a query to your db to get the times.

than use something like this:

// Multiplying with varaibles
$factorA = .01;
$factorB = number_format(system_value('usercount'), 0);
$product = $factorA * $factorB + .25;
echo $product;
?>

What this one does is count a total number of user on the website, than use factorA and multiplies that with factorB + a certain value.

But this won't bring it in-line to what you want, but you could run some code to work it out. (just divide by .60?)

J








Hi All I have two tables with columns of times that it took to perform tasks eg: 8:40 6:50 8:30 10:55 --------- 34:55 total time taken to complete the tasks in hours and minutes I am able to add the times with sql however I need to add the totals to cone up with a grand total and because of the makeup of the tables I cant use sql. I am there for going to have to use php code and this is where the problem comes in because in sql there is SEC_TO_TIME and TIME_TO_SEC functions that allow easy addition of the times but I cant find an equivalent in php. Does any one know of a way that I can add to times together in php.

--0-1118794499-1141525095=:5417--