Page 1 of 1

Timestamp values

Posted: Wed Aug 18, 2004 8:54 am
by mzfp2
Hi

One of my tables has a timestamp which identifies the time and date the record was inserted into the database (timestamp is PHP Generated).

I require to delete records that are one month old everytime the table is accessed, just wondering, how can I calculate this?

Anything would help here

Many thanks

Muzz

Posted: Wed Aug 18, 2004 9:33 am
by pickle
This should do it:

Code: Select all

<?PHP
$prev_month = strtotime("-1 month");
$query = "DELETE FROM my_table WHERE timestamp < '$prev_month'";
?>