Calculate Relative Time Ago

Here you may find some useful snippets for calculating relative time for different purposes: to get info from a column within certain date, like the latest 7 days, to get time interval etc.

[View All Snippets]
Show Plain Text »
  1. -- Relative time with interval
  4. -- Select all users that were updated in the last 24 hours.
  5. SELECT * FROM users
  6. WHERE users.updated > DATE_SUB(NOW(), INTERVAL 24 HOUR);
  8. -- Select all users that were updated in the last 7 days.
  9. SELECT * FROM users
  10. WHERE users.updated > DATE_SUB(NOW(), INTERVAL 7 DAY);
Create Your Free Account
Please remember that this information is essential to use our services correctly.
After creating the account you will be able to download all of our FREE products.
Fields marked with * are mandatory

Please send me information about updates, new products, specials and discounts from ApPHP!
We recommend that your password should be at least 6 characters long and should be different from your username/email. Please use only letters of the English alphabet to enter your name.

Your e-mail address must be valid. We use e-mail for communication purposes (order notifications, etc). Therefore, it is essential to provide a valid e-mail address to be able to use our services correctly.

All your private data is confidential. We will never sell, exchange or market it in any way. Please refer to Privacy Policy.

By clicking "Create Account", you are indicating that you have read and agree to the ApPHP Terms & Conditions.