Re: comparing stored timestamp with NOW()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux