Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 352
Jacobson Avatar asked Feb 25 '23 23:02

Jacobson


1 Answers

SELECT *
FROM table
WHERE timestampcol < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 10 DAY)
like image 59
Dan Grossman Avatar answered May 02 '23 17:05

Dan Grossman