php - Calculate 2 timestamp in attendance -
any ideas how calculate attendance datetime
in mysql.
for example: want total hours person worked in day. in given.
mysql structures:
----------------------------------------------------- id | datetime | status | employeeid ----------------------------------------------------- 1 | 18-feb-13 8:00:00 | check in | 100a 2 | 18-feb-13 10:00:00 | check in | 100a 3 | 18-feb-13 17:00:00 | check out | 100a
still total hours 8 hours excluding break time 12:00 pm.
here's php way date math:
$datetime1 = datetime::createfromformat('d-m-y g:i:s', '18-feb-13 8:00:00'); $datetime2 = datetime::createfromformat('d-m-y g:i:s', '18-feb-13 17:00:00'); $interval = $datetime1->diff($datetime2); $elapsed = $interval->format('%h hours %i minutes %s seconds'); echo $elapsed;
see in action
you'll need more math deal breaks should started.
reference
datetime dateinterval php mysql date datetime
No comments:
Post a Comment