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 Link to comment https://forums.phpfreaks.com/topic/217968-how-to-use-php-to-delete-mysql-logs-3-hours-old/ 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"); Link to comment https://forums.phpfreaks.com/topic/217968-how-to-use-php-to-delete-mysql-logs-3-hours-old/#findComment-1131181 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.