Hi there
i was wondering what would be the best way of checking if an entry in the db is older than, say, 24 hours
I imagine that i could use date(); to generate a date and time when inserting into the DB - but I would like to be able to delete anything older than the given time limit
what's a sort of standard way of tackling this prob ?
thanks for your help
You could just setup an int10 in the db, and use something like...
$time = time(); // Delete any entry older than 20 minutes for maintenance purposes $delete_query = 'DELETE FROM '.$db_name.'.'.$db_prefix.'table_name WHERE time<='.($time-(60*20));
...you could also use a timestamp in the db and leave the calculations up to mysql, but either way would work.
ok I've just looked up time() in the manual - I wasn't even aware of it's existence !
your solution looks just the ticket
presumably for 24 hours i would do
WHERE time<='.($time-(246020));
thanks for that - it's a big help