title: check if datetime from sql is today
body: <p>I have a date returned from an sql query (a datetime type field) and want to compare it to today's date in PHP. I have consulted php manual and there are many ways to do it. I finally came up with a solution comparing strings, but I would like to know if there are either any 'better' (best practice), cleaner or faster ways to do it. This is my solution:</p>
  
  <pre><code>// $sql_returned_date='2008-10-17 11:20:04'
  
   $today = new DateTime("now");
   $f_today=$today-&gt;format('Y-m-d'); //formated today = '2011-03-09'
   $sql_date=substr($sql_returned_date,0,9); //I get substring '2008-10-17'
   if($f_today==$sql_date)
   {
      echo "yes,it's today";
   }else{
      echo "no, it's not";
   }
  </code></pre>
  
  <p>thanks</p>