Hi,
What about something like this :
update your_table
set visible = 0
where your_timestamp_field >= UNIX_TIMESTAMP(subdate(now(), interval 1 hour))
As explanation, here's a select that might help you :
mysql> select now(), subdate(now(), interval 1 hour), UNIX_TIMESTAMP(subdate(now(), interval 1 hour))\G
*************************** 1. row ***************************
now(): 2009-09-17 18:58:31
subdate(now(), interval 1 hour): 2009-09-17 17:58:31
UNIX_TIMESTAMP(subdate(now(), interval 1 hour)): 1253203111
1 row in set (0.00 sec)
Here :
- now() gets the current date and time
- the
subdate() gives 1 hour before now
- and
unix_timestamp() converts that to a unix timestamp
You might also do a substraction of 3600 seconds on UNIX_TIMESTAMP(now()), instead of using subdate... But I like the subdate call : I find it easier to immediatly understand that you want 1 hour (and not a magic number like 3600)