So, I have a field in my users table named last_active
which updates every time a user reloads a page.
It\'s stored in unix timestamp.
I would like
The simplest approach to this is to take the last_active
timestamp, and the current timestamp with time()
. Then subtract the last active from the current timestamp, and then you simply divide the result with the amount of seconds in a day to get difference in days, amount of seconds in an hour to get difference in hours and so on.
This approach may be slightly inaccurate in some special cases (leap years, etc.) but it should suffice for your simpler usecase