title: Get absolute days away
body: <p>I want to get the absolute days away a datetime is from today.  For example, i would like to know if a date is 2 days away, or 78 days away, or even 5,239 days away (not likely, but you get the idea).  I am using an MS SQL database which is returning datetimes where the time components are all 00:00:00.</p>
  
  <p>date_diff returns relative values that you then have to do some crazy math with to get absolute dates do to calculating months, years, etc.</p>
  
  <p>Also, i am having issues getting the date component only of today's date in php.</p>
  
  <p>Edit:
  Thanks to mr. w. This is what i ended up with:</p>
  
  <pre><code>    $date = $row['AirdateDateTime'];
      $today = date_create(date("Y-m-d"));
      $away = date_diff($today, $date);
      $d = $away-&gt;format("%R%a");
  </code></pre>
  
  <p>The date_create() part was the part i was originally missing to convert to an actual datetime. Also, the format needs to be <code>%R%a</code>. Using <code>%R%d</code> only works for dates in this month.</p>