Jacobson Jacobson - 2 months ago 6
MySQL Question

How to detect if a certain amount of time has passed in PHP/MySQL?

I have a time stamp in a MySQL database that looks like this:

2011-02-23 20:39:49


How can I detect if a certain amount of time has passed since the creation of that timestamp. In other words if the timestamp was created on February 23, 2010 at 8:39:43 P.M. how can I detect if exactly 10 days (240 hours) have passed since the creation of this timestamp? How to do this in PHP?

Answer
SELECT *
FROM table
WHERE timestampcol < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 10 DAY)
Comments