Possible Duplicate:
How to get time difference in minutes in PHP
I am working on an attendance table to calculate the late and very late employees. I am storing the login time in the table (Type: time). I am able to get the time from the database and i would like to show the time difference in the separate column.
i.e., if employee logged on or before 09:00:59
, then its right time and the time diff should be shown as null. If he logs in after the time i.e, 09:01:00
or later the time difference should be 00:00:01
. Like wise i need to calculate the differences in time.
One time is constant i.e., 09:00:59
and another one i am getting from database table. Need to get diff between both.
I am working in PHP.
Hope my question is clear.
Thank you in Advance.
You can also use DateTime class:
Result:
You can use strtotime() for time calculation. Here is an example:
Demo
Check the already-asked question - how to get time difference in minutes: