MySQL Time Ago function


/ Published in: MySQL
Save to your folder(s)

Retrieves a relative time in a MySQL Query


Copy this code and paste it in your HTML
  1. # Relative Time
  2.  
  3. # For example:
  4. # Select all users who were updated in the last 25 hours.
  5. SELECT * FROM users
  6. WHERE users.updated > DATE_SUB( NOW( ) , INTERVAL 25 HOUR );
  7.  
  8. # Select all users who were updated in the last 2 days.
  9. SELECT * FROM users
  10. WHERE users.updated > DATE_SUB( NOW( ) , INTERVAL 2 day );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.