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?
SELECT *
FROM table
WHERE timestampcol < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 10 DAY)
$isDone = time() - strtotime($row['time']) >= 240 * 3600;
select id
from foo
where date_field+interval 10 day >NOW()
In SQL for MySQL:
SELECT * FROM mytable WHERE DATE_ADD(date_column, INTERVAL 10 DAY) > NOW()
This query will find any rows where the date_column contains a datetime value more than 10 days into the future from the current time.
SELECT the_timestamp < NOW() - INTERVAL 240 HOUR AS more_than_240_hours_ago FROM table