Page 1 of 1

working with hours / sum of hours

Posted: Sat Jun 09, 2012 11:23 am
by headbull
I was wondering if anybody have any good ideas to working with hours/sum of hours ?

I'm in need of "saving" start point and end point, getting the total of hours between the start and end point (typicaly a workday or less) - i would need this data to be saved and handeled from an MySQL db.

Is the best thing to save timestamps, and work with them, or to save date in one field and start and end time in the other fields ?

Re: working with hours / sum of hours

Posted: Sat Jun 09, 2012 10:40 pm
by TylerH4
I would do as you suggested, save the start and end timestams as their own field. When you need to find the total number of hours, you could simply do:

Code: Select all

$hours = ($endTime-$startTime)/60;

Re: working with hours / sum of hours

Posted: Sun Jun 10, 2012 6:27 pm
by headbull
Any ideas how to solve the issue if the user sets startime to 21:00 and endtime 02:30 ? I really wont the user only to be able to choose one date.. Any ideas or solutions to how the system can spot/correct the date on the end time ?