Time Calculation |
2/6/2009 9:39:30 AM |
PHPRunner General questions | |
F
fpilot author
I am making a time in and out module for employees and am not sure how should I set up the fields in the table and process it to find the difference of time resulting in number of hours and minutes. Also if the employee started at 3pm and finished at 1am next day then the date change effects the number of hrs if I just subtract the hours and minutes alone. Pls advise. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=10841&image=1&table=forumtopics' class='bbc_emoticon' alt=':o' /> |
|
A
|
amuro 2/8/2009 |
maybe you can try this. |
F
|
fpilot author 2/11/2009 |
Thanks a bunch Amuro. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=37705&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' /> maybe you can try this. table column: $login_time, $logout_time $login_time = date("Y-m-d H:i:s"); // to record the time user login $logout_time = date("Y-m-d H:i:s"); // to record the time user logout $login_s = strtotime($login_time); // seconds from 1970-00:00:00 to $login_time $logout_s = strtotime($logout_time); // seconds from 1970-00:00:00 to $logout_time $dif_s = $logout_s - $login_s; $hrs = (int)($dif_s/60/60); $mins = (int)(($dif_s%3600)/60); $hrs and $mins are the variable you want. hope could be a bit help to you! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=37705&image=2&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' /> |