onlyican Posted January 28, 2008 Share Posted January 28, 2008 Hey all. Been a while. Here is the situation. I am storing someones Start and Finish time for work in the database using strototime() So I have the date. TO work out the number of hours they have worked that day is simple $DiffTime = ($FinishTime - $StartTime); //For some reason, above adding an hour. remove this $DiffTime = strtotime("-1 hour", $DiffTime); //Show results as wish return date("G", $DiffTime)." hours ".date("i", $DiffTime)." mins"; Now here is the tricky bit. I want to somehow work out how many hours in total they have done. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/88177-solved-help-trying-to-work-something-out/ Share on other sites More sharing options...
rajivgonsalves Posted January 28, 2008 Share Posted January 28, 2008 try this return floor($DiffTime/3600)." hours ".($DiffTime%3600/60)." mins"; Link to comment https://forums.phpfreaks.com/topic/88177-solved-help-trying-to-work-something-out/#findComment-451136 Share on other sites More sharing options...
onlyican Posted January 28, 2008 Author Share Posted January 28, 2008 You mis-understood, I got the time for that day in the example but say I have 4 days If I add all the Start Times up, I could run into problems The only thing I can think off is adding up the Hours and Minutes Then what do I do when I have 200 minutes. We know its 3 hours 20 mins, but How do I get the 20 minutes? Link to comment https://forums.phpfreaks.com/topic/88177-solved-help-trying-to-work-something-out/#findComment-451141 Share on other sites More sharing options...
rajivgonsalves Posted January 28, 2008 Share Posted January 28, 2008 taking the above example the code will be as follows <?php $intMinutes = 200; //Show results as wish echo floor($intMinutes/60)." hours ".($intMinutes%60)." mins"; ?> Link to comment https://forums.phpfreaks.com/topic/88177-solved-help-trying-to-work-something-out/#findComment-451146 Share on other sites More sharing options...
onlyican Posted January 28, 2008 Author Share Posted January 28, 2008 Cheers, it works Link to comment https://forums.phpfreaks.com/topic/88177-solved-help-trying-to-work-something-out/#findComment-451219 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.