title: PHP DateTime diff weird result
body: <p>I am having a weird problem with PHP's DateTime diff method. I've been using DateTime methods for some while now and thought I've got the hang of it, but this problem amazes me. </p>
  
  <p>I am using the diff method to determine the number of months/days between two dates.
  Today, I used the following code:</p>
  
  <pre><code>$start = new DateTime('2012-03-01');
  $end = new DateTime('2012-03-31');
  
  $period = $start-&gt;diff($end);
  
  var_dump($period);
  </code></pre>
  
  <p>Which produced the following output:</p>
  
  <pre><code>object(DateInterval)[3]
    public 'y' =&gt; int 0
    public 'm' =&gt; int 1 // Shouldn't this be 0?
    public 'd' =&gt; int 1 // And where does this come from? Would expect 30.
    public 'h' =&gt; int 0
    public 'i' =&gt; int 0
    public 's' =&gt; int 0
    public 'invert' =&gt; int 0
    public 'days' =&gt; int 30
  </code></pre>
  
  <p>As my comment above says, where the hell does the 1m1d come from (I would expect 0m30d). I can't for the life of me figure out where it gets this value from. I also tried putting the midnight timestamp <code>00:00:00</code> behind both dates to make sure it wasn't a time thing, but that made no difference to the output.</p>
  
  <p>Can anybody explain this outcome to me?
  This problem occurs on my Debian development server, running PHP 5.3.3 with Xdebug 2.1.1 and Suhosin 0.9.32.1 installation.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Reproduced this problem on my production server, which is on CentOS 6.0 with "raw" PHP 5.3.8 without any extensions/patches.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>I managed to find a "workaround" (only working at this moment in time). If I change the absolute dates to:</p>
  
  <pre><code>$start = new DateTime('first day of next month');
  $end = new DateTime('last day of next month');
  </code></pre>
  
  <p>It does give 0m30d as output. Still, I'm stumped by the above, so if anyone has a clue about that, please let me know!</p>