title: How to determine if a date is more than three months past current date
body: <p>I am getting a date back from a mysql query in the format YYYY-MM-DD.</p>
  
  <p>I need to determine if that is more than three months <strong>in the past</strong> from the current month.</p>
  
  <p>I currently have this code:</p>
  
  <pre><code>$passwordResetDate = $row['passwordReset'];
  $today = date('Y-m-d');
  
  $splitCurrentDate = explode('-',$today);
  $currentMonth = $splitCurrentDate[1];
  
  $splitResetDate = explode('-', $passwordResetDate);
  $resetMonth = $splitResetDate[1];
  
  $diferenceInMonths = $splitCurrentDate[1] - $splitResetDate[1];
  
  if ($diferenceInMonths &gt; 3) {
      $log-&gt;lwrite('Need to reset password');
  }
  </code></pre>
  
  <p>The problem with this is that, if the current month is in January, for instance, giving a month value of 01, and <code>$resetMonth</code> is November, giving a month value of 11, then <code>$differenceInMonths</code> will be -10, which won't pass the if() statement.</p>
  
  <p>How do I fix this to allow for months in the previous year(s)?
  Or is there a better way to do this entire routine?</p>