Adding times in php

Adding times in php

am 04.03.2006 08:13:13 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 times in php

am 04.03.2006 16:19:27 von Bastien Koert

I would consider adding either:

1. a virtual column in the sql to add up the times
2. issue another sql statement to get a total
3. store a total in a cookie / session initially

bastien


>From: "Allan"
>Reply-To: "Allan"
>To: php-db@lists.php.net
>Subject: [PHP-DB] Adding times in php
>Date: Sat, 4 Mar 2006 15:13:13 +0800
>
>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
>

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