[RESOLVED] MySQL's datetime - Hours passed?
Posted: Mon Jun 02, 2008 7:11 pm
I wanted to make it so it would check if it's been an hour since any database entries with their IP. If not, don't let them post!
I figured it out using strtotime.
Jake
I figured it out using strtotime.
Code: Select all
$query = "SELECT date, ip FROM A_Database_Name";
$result = mysql_query($query);
while(list($date, $postedIP) = mysql_fetch_array($result))
{
//If the IP addresses match
if($postedIP == $ip)
{
$posted = strtotime($date);
$now = strtotime(date("Y-m-d H:i:s"));
$seconds = $now - $posted;
$hours = $seconds / 3600;
if($hours < 1)
{
$error .= "You must wait 1 hour before re posting.";
$continue = false;
break;
}
}
}