Unique visitors log

I’m trying to do a simple unique visitors log.

I’m not sure how to use the datetime to see if the visitor(IP) has been there the same day.

So I’m not sure about the part that is log_date=‘$today’

Below is the code


// C1: GETS TODAY'S DATE
//     SEE Date And Time TUTORIAL
$today = date("Y-m-d");

// C2: GETS IP ADDRESS OF VISITORS
$log_ip = $_SERVER['REMOTE_ADDR'];

// D: CHECKS IF IP OF VISITOR WAS LOGGED TODAY
$check = mysql_query("SELECT * FROM log WHERE log_ip='$log_ip' AND log_date='$today'");

$unique = mysql_num_rows($check);

// IF IP WAS LOGGED
if ($unique > 0)
{
echo "visitor has been here today";
  
} else {	

// GETS THE SITE THAT REFERRED YOUR VISITOR
$log_ref = $_SERVER['HTTP_REFERER'];

// GETS THE BROWSER YOUR VISITOR IS USING
$log_browser = $_SERVER['HTTP_USER_AGENT'];
  
$log_ip = $_SERVER['REMOTE_ADDR'];
  
$log_date = date('Y-m-d G:i:s');


//Create INSERT query
$qry = "INSERT INTO log (log_date, log_ip, log_ref, log_browser) VALUES ('$log_date','$log_ip','$log_ref','$log_browser')";
      
$result = mysql_query($qry400) or die("Query failed"); 
if ($result){
	
header("location: index.php"); 
exit();
	
}
	  
}