title: php comparing dates for day change
body: <p>I have found hundreds of questions and answers for topics SIMILAR to this on SO, however, none match my needs specifically and I am stumped.</p>
  
  <p>I have a variable in y-m-d format and I need to see if it was created on the previous calendar day (not 24 hours previous, but on the previoous calendar day).</p>
  
  <p>ie.
  $tDate = '12-05-2';</p>
  
  <p>If object created May 2, 2012 at 11:59pm(stored time) I need a comparison to May 3, 2012 12:01 am(current time) to equal true.</p>
  
  <p>If object created May 2, 2012 at 11:51pm(stored time) I need a comparison to May 2, 2012 11:58pm(current time) to equal  false.</p>
  
  <p>I know if these were stored in a MySQL db and pulled from a field, MySQL could figure that out easily.  In this case, however, that solution is not an option.</p>
  
  <p>This comparison must be done entirely in php.</p>
  
  <p>I know it's an eccentric question, but hey, that's what the guru's at StackOverflow excel at!  Looking forward to seeing the replies!</p>
  
  <p><em>UPDATE</em></p>
  
  <p>Figured this out as:</p>
  
  <pre><code>    $dTest = '12-05-02';
      $dTest = explode('-',$dTest);
      $dTest2 = date('y-m-d');
      $dTest2 = explode('-',$dTest2);
  
      if ($dTest[2]&lt;$dTest2[2]){
          echo '&lt;br /&gt;Posted Yesterday&lt;br /&gt;';
      } else {
          echo '&lt;br /&gt;Posted Today&lt;br /&gt;';
      }
  </code></pre>
  
  <p>Is there a more efficient solution?  Seems to work, but I figure there must be a more optimal/elegant solution?</p>
  
  <p><em><strong>SOLVED</em></strong></p>
  
  <pre><code>$tHolder = '12-05-12';
  $voteDate = date("y-m-d", strtotime($tHolder));
  $today = date("y-m-d", strtotime("today"));
  
  if ($voteDate === $today)
  {
     echo "this was today's post";
  }
  elseif ($voteDate &lt; $today)
  {
     echo "this was previous to today";
  }
  </code></pre>