plznty Posted November 6, 2010 Share Posted November 6, 2010 basically could somebody help me with information on having a php script that deletes mysql rows which are older than 3 hours old. I know MYSQL table will need a date/time column but how can I only target ones which are 3 hours old+. Thanks Quote Link to comment Share on other sites More sharing options...
Yucky Posted November 6, 2010 Share Posted November 6, 2010 You could store a Unix timestamp with every record and then do something along the lines of: define("EXPIRY_TIME", 10800); //Three hours in seconds $deleteTime = mktime() - EXPIRY_TIME; //Delete everything created before this timestamp $query = mysql_query("DELETE FROM `logs` WHERE `timestamp` < $deleteTime"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.