title: How can I efficiently compare two DateTimes and check if they are the same day?
body: <p>I have two <code>DateTime</code> objects</p>
  
  <pre><code>$lastDate = $entity-&gt;getDate(); // is a DateTime with same format as $today
  $today    = \DateTime::createFromFormat('!Y-m-d', date('Y-m-d'));
  </code></pre>
  
  <p>Now I want to check, if those two dates are the same day, or if they are more than one day apart (but this shall also include if <code>$lastDay</code> is yesterday at 11pm and <code>$today</code> is 1 am the new day).</p>
  
  <p>What I have so far is</p>
  
  <pre><code>$diff = $today-&gt;diff($lastDate);
  
  if($diff-&gt;days &gt; 0) {
      $return = false;
  } else {
      $return = true;
  }
  </code></pre>
  
  <p>The problem is: This seems to count if the dates are more than 24 hours away from each other and only sets to <code>true</code> if that is the case.</p>
  
  <p>I could think of comparing them by comparing <code>$date-&gt;format('d');</code>, but this would imply that I check year and month as well. I know this would work flawlessly, but this would be a five-liner or so.</p>
  
  <p>So my question is: Is there a more <em>efficient</em> way to check this? Any operation like <code>diff()</code> that gives me the result in a one-liner?</p>