Jump to content

TimeSheet Application


JustinK101

Recommended Posts

I am devolping a timesheet application, and I need to figure out how to subtract times and get total hours in a single day.

I will have the following variables in a mysql table for each day, i.e. each row stores the following datetime mysql variables:

[b]Acutally now I am thinking about it, should each of these clockIn and clockOut mysql entries simply be a time data type instead of datetime? Since, each record is a single day, in theory I shouldnt need the date. Thanks for advice on this as well.[/b]

EXAMPLE:

[code]
clockIn1 = 2006-06-15 09:00:51
clockOut1 = 2006-06-15 12:00:12

clockIn2 = 2006-06-15 13:00:18
clockOut2 = 2006-06-15 15:30:44

clockIn3 = 2006-06-15 15:45:23
clockOut3 = 2006-06-15 17:00:14

clockIn4 = 0000-00-00 00:00:00
clockOut4 = 0000-00-00 00:00:00

clockIn5 = 0000-00-00 00:00:00
clockOut5 = 0000-00-00 00:00:00
[/code]

NOTE: clockIn and clockOut 4 and 5 were not used in this example but they could have been. Also the opposite is true, there may be a case where ONLY clockIn1 and clockOut1 are filled, the other 4 pairs of variables could be zeroed out.

[b]How do I calulate the total amount of time in this example work day in hours:minutes:seconds from this data? Thanks guys![/b]
Link to comment
https://forums.phpfreaks.com/topic/12124-timesheet-application/
Share on other sites

Convert the time into the number of seconds since 1-1-1970 by using strtotime() or one of the other date/time functions. Subtract. Take the result and divide by 3600 (the number of seconds in an hour).

There have been quite a few posts on how to return the number of hours, minutes and seconds in the last few weeks. They shouldn't be hard to find.

Ken
Link to comment
https://forums.phpfreaks.com/topic/12124-timesheet-application/#findComment-46170
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.