So, I have isOnline
(boolean) and lastTimeSeen
(DateTime) fields in my users table.
Everytime a user loads a page on my application, lastTimeSeen will be updated for him.
Then, I want to make a SQL query that will retrieve all users that have the isOnline
column equals to 1 and where lastTimeSeen
column is superior to 5 minutes to set isOnline
to 0.
Though, I have no idea how to compare a DateTime with current time in order to check if the user has not been seen in the last 5 minutes.
Do I have to do that with PHP?
UPDATE FROM users WHERE isOnline = 1 AND lastTimeSeen => comparison to make
Could you guys help me with that?