title: DATEDIFF creating function for php code
body: <p>I am trying to convert the following MYSQL SELECT code in  to php code: <code>DATEDIFF(date, NOW()) &lt;= 31</code> basicaly if the date is less than or equal to 31 days do the rest.</p>
  
  <p>So far what I have done is the following </p>
  
  <pre><code>$today = new DateTime('now');
  $date = $row['date'];
  $diff = date_diff($date,$today);
  </code></pre>
  
  <p>and than inside if cycle I have the condition: <code>if ($diff &lt;= 31)</code></p>
  
  <p>My Sql date column is only specified as a Date not DateTime I am getting the following error and I am wondering how I can get calculated the date only</p>
  
  <pre><code>Warning: date_diff() expects parameter 1 to be DateTime, string given in D:\xampp\htdocs\website\c.php on line 299
  bool(false) 
  Warning: date_diff() expects parameter 1 to be DateTime, string given in D:\xampp\htdocs\website\c.php on line 299
  bool(false)
  </code></pre>
  
  <p>Aditional Information which makes the answers bellow to not be working is that in my SQL query I am preformating the date with <code>DATE_FORMAT(date,'%d %b %Y') as date</code></p>
  
  <p>Any help will be very welcome. Thanks!</p>