1

I have a db with some customers data. There I store their last login time as datetime.

I want to run a cron php script every min which will query mysqli for their last login datetime and if that was more than 20 mins in the past i will run some js popup etc (something like NOW() - last_login).

Anyway I am trying to query the db directly for that kind of users based on that 20 min time difference.

With php it's easy to filter results but I want to bring directly results from my mysql db without any intermediate process from php.

How can I accomplish this?

  • Ok, i 've found the solution and i want to share it with you. "SELECT * FROM tbl_name WHERE dt_column < DATE_SUB(NOW(), INTERVAL 20 MINUTE)" This brings all entries were last login dt was more than 20 mins in the past. – Marios Fakiolas Jan 18 '13 at 19:28
  • You can add that as an answer (of your question). – ypercubeᵀᴹ Jan 18 '13 at 20:24
1

Ok, i 've found the solution and i want to share it with you.

SELECT * FROM tbl_name WHERE dt_column < DATE_SUB(NOW(), INTERVAL 20 MINUTE)

This brings all entries were last login was more than 20 mins in the past.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.