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
IN PHP HOW WE CAN SHOW TWO DAYS WORKING HOURS
Moderator: General Moderators
Re: IN PHP HOW WE CAN SHOW TWO DAYS WORKING HOURS
Convert the two times to minutes, add them, then convert the result back to hours.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: IN PHP HOW WE CAN SHOW TWO DAYS WORKING HOURS
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
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