Re: comparing stored timestamp with NOW()
| From: | Andrés G. Montañez | Date: | Tue, 24 Feb 2009 23:00:59 +0000 |
| Subject: | Re: comparing stored timestamp with NOW() | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46006@lists.php.net to get a copy of this message | ||
If your timestamps is an UNIX Timestamp,
and your DB is MySQL, this should do the trick
$days = 7;
$sql = 'SELECT (UNIX_TIMESTAMP() - ' . $timeStamp . ') <= (3600*24*' .
$days . ');';
3600*24 is one day in seconds, so multiply it by the days limit (7 days).
Example Query:
mysql> SELECT (UNIX_TIMESTAMP() - 1235861716) <= (3600*24*7) AS valid FROM dual;
+-------+
| valid |
+-------+
| 1 |
+-------+
Enjoy.
--
Atte, Andrés G. Montañez
Zend Certified Engineer
Montevideo - Uruguay