Re: [PHP-DB] comparing stored timestamp with NOW()
[email protected] (Andrés G. Montañez)
| Newsgroups | php.db |
|---|---|
| Message-ID | <[email protected]> |
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