Page 1 of 1

IN PHP HOW WE CAN SHOW TWO DAYS WORKING HOURS

Posted: Fri Feb 13, 2009 2:36 am
by gagan
HI EVERYONE,

I have one problem, as i calculate two time like today i have worked 9.43 hours and last day i worked 8.20 hours when i calculate total time of these two day then it shows 17.63 hours but i want to show this with the help of php , this should come as like 18.03 hours.

How i can do this , please help me.

regards,
Gagan

Re: IN PHP HOW WE CAN SHOW TWO DAYS WORKING HOURS

Posted: Fri Feb 13, 2009 2:42 am
by onion2k
Convert the two times to minutes, add them, then convert the result back to hours.

Re: IN PHP HOW WE CAN SHOW TWO DAYS WORKING HOURS

Posted: Fri Feb 13, 2009 2:47 am
by Mark Baker
You're getting:
9.43
8.20 +
-----
17.63

That is standard mathematics.


To do:
9:43
8:20 +
-----
18:03

You have two choices.
1) You use a PHP date/time stamp for your times, and the date functions to convert input to date/timestanp and reformat it back for display
2) You convert the hours and minutes to a true decimal using hours + minutes/60, and then reverse the process to display the result