John
John

Reputation: 3050

Check if the user been active in the latest 15 minutes

I'm really stuck at this, I need to check two timestamps, and figure out if the user has been active for the last 15 minutes...

In database last_active int 11

while ($m = $this->db->fetch($query))
{
    $members[] = $m;

//What to do here:
    if ($members['last_active'] 
}

Upvotes: 0

Views: 420

Answers (1)

Your Common Sense
Your Common Sense

Reputation: 157895

You're doing it wrong.

You have to do it at the SQL level, not application level.

Make your query like

SELECT * FROM users WHERE last_active > unix_timestamp() - 60*15

Upvotes: 1

Related Questions