Re: Problems with time calculation
| From: | David Robley | Date: | Thu, 28 Sep 2000 08:23:12 +0000 |
| Subject: | Re: Problems with time calculation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17877@lists.php.net to get a copy of this message | ||
On Thu, 28 Sep 2000, Mai Truong wrote:
> thanks for answering. Ok, I send you parts of the code:
> the create_table thing is:
> $sql="create table work
> (... start time, end time, ...)
>
> then the other script:
> ... $start = mysql_result($result,$i,"beginn");
> $end = mysql_result($result,$i,"ende");
> $work = $end - $start
> echo &work; ...
>
>
> or should I take a different time /date function for the calculation?
>
I see - you said are using the time type for storage, so you should let
mysql do the calculation for you. Your query might be something like
SELECT (ende - beginn) AS elapsed FROM work
(and add whatever else you need) and you can get the difference in
mysql_result($result,$i,"elapsed") and that should be in hh.mm.ss format.
The date() function needs a Unix style date/time, so if you wanted to go
that way, you could store your times as timestamp. But that is doing it the
hard way, as you then have to call the data function in php.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA