westman Posted October 25, 2011 Share Posted October 25, 2011 hi allam trying to get posts to auto delete from mysql database after the post is 4 weeks old $sql = mysql_query("UPDATE board SET mail='$mail', date 'NOW' WHERE id='$id'")or die (mysql_error());how do i change my script? Link to comment Share on other sites More sharing options...
birbal Posted October 25, 2011 Share Posted October 25, 2011 something like this. assuming you are using timestamp to store post time $timeEdge=time()-(4*7*24*60*60) $qry="DELETE FROM table WHERE timeofpost>$timeEdge"; Link to comment Share on other sites More sharing options...
westman Posted October 25, 2011 Author Share Posted October 25, 2011 out of$timeEdge=time()-(4*7*24*60*60)what number is the days and what number is the mounts? Link to comment Share on other sites More sharing options...
westman Posted October 25, 2011 Author Share Posted October 25, 2011 ok i just use this on my server and it worked $days = 30;$time = time() - (60 * 60 * 24 * $days);$sql = mysql_query("DELETE FROM board WHERE date < '$time'")or die (mysql_error());but can some one help me understand all of the numbers (60 * 60 * 24 * $days and also 4*7*24*60*60) Link to comment Share on other sites More sharing options...
birbal Posted October 25, 2011 Share Posted October 25, 2011 it is just converting the day to seconds60 =second60 =minute24 =hours60 * 60 * 24 will produce the seconds of one day. Link to comment Share on other sites More sharing options...
westman Posted October 25, 2011 Author Share Posted October 25, 2011 so if i use $days = 90;$time = time() - (60 * 60 * 24 * $days); is this 12 weeks? Link to comment Share on other sites More sharing options...
Krewe Posted October 25, 2011 Share Posted October 25, 2011 1min = 60sec60sec*60minutes = 1 Hour60sec*60minutes*24hours = 1 day60sec*60minutes*24hours*7days = 1 week60sec*60minutes*24hours*7days*12weeks = 12 Weeks. So it would be60*60*24*7*12 = 12 Weeks Link to comment Share on other sites More sharing options...
westman Posted October 25, 2011 Author Share Posted October 25, 2011 i thank every one for there help and support thank you. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 25, 2011 Share Posted October 25, 2011 If you don't want to force PHP to do the same math every time, there are 86400 seconds in 1 day. Link to comment Share on other sites More sharing options...
westman Posted October 25, 2011 Author Share Posted October 25, 2011 thank you that helpful Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.