Ne bu böyle bir şey:
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)
İşte:
- now() Geçerli tarih ve zaman alır
subdate()
şimdi 1 saat önce verir
- ve
unix_timestamp()
dönüştüren bir unix zaman damgası
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)