Q:

Calculating last login time from database mysql

I currently have a database which contains last_login and last_logout columns with the datatype set to datetime. When a user logs in and logs out of the system, the time is updated in both of those columns.
I would now like to create a notification that informs the user of when they previously logged into the system. I would like to display the answer in hours, for example (23 hours ago or 128 hours ago).
I just can't figure out how to perform calculations in PHP with the values in each of these columns. Please help.
I apologise if this question is hard to understand.

A:

Do it in mysql
Select TimeStampDiff(HOUR,LastLoginTime,Now()) From MyLoginTable

For instance

