title: php how to tell if the difference between two times falls on today, yesterday or other?
body: <p>I have been looking through various posts on here to find my solution but i can't find one :(</p>
  
  <p>so what i am after is a way of finding the exact difference between to dates. I currently have the following code</p>
  
  <pre><code>$date = time();
  $publishedDate = strtotime($item-&gt;published_time);
  $datediff = $date - $publishedDate;
  $daysListed = floor($datediff/(60*60*24));
  
  if($daysListed &gt;= 2)
  {
      $days = $daysListed." days ago";    
  }
  elseif ($daysListed == 1)
  {
      $days = $daysListed." yesterday";   
  }
  elseif ($daysListed &lt; 1)
  {
      $days = "today";
  }
  </code></pre>
  
  <p>which does a pretty good job, the main flaw i have with this is say my user submits a post at 23:59pm last night the above code will return a value of "today" because $datediff is returning less than 24 hours, even though it was posted yesterday. Is there a more accurate way of getting the correct value returned?</p>
  
  <p>Appreciate your help
  Luke</p>