seanD Posted June 30, 2010 Share Posted June 30, 2010 Hi, I'm pretty new to php, and I've been getting by on google searches and several books for references. But I seem to be stuck on this one problem. I imported this data from a csv file which tracks times employees clock in and out of work. I was able to import the csv into mysql using php. The csv contains one row per transaction. Each time you clock in or out, it creates a new row. See the following: employee1, 5445 ,07:10:49,04/20/2010 employee1, OUT, 15:40:37,04/20/2010 employee1, 5445, 07:20:12,04/21/2010 employee1, OUT, 15:58:04,04/23/2010 The second column indicates whether a person clocked in or out. The third is the time, the last is the date. I've been able to display the data in a table, but I would like to subtract the time from each different row to display the hours worked. I don't usually post on forums in fear of getting flamed. So forgive me if I broke any rules. Appreciate any help I can get. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 1, 2010 Share Posted July 1, 2010 I'm not sure how you're looping through these, but the math is simple (I'm just making up variables names): $hours = ( strtottime($out_date . ' ' . $out_time) - strtottime($in_date . ' ' . $in_time) ) / 3600 // seconds in an hour Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.