Jump to content

Auto Delete Mysql Date


westman

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...