title: Why does date gives me a wrong date?
body: <p>I want to calculate a date based on a timestamp and some other informations.</p>
  
  <p>My function looks like:</p>
  
  <pre><code>function getLastDeliveryDate($timestamp,$endOfMonth=true,$extraMonth=0){
  
      $days               = 0;
      $extraDays          = 0;
      $endOfCurrentMonth  = 0;
      $tsDay              = 86400;
  
      if($endOfMonth){
          $endOfCurrentMonth = date("t", $timestamp) - date("d",$timestamp);
          //rest of days in current month. In this sample 16 days
      }
  
      for($i=0;$i&lt;$extraMonth;$i++){
          $x = $i + 1; 
          $date = new DateTime(date("Y-m-d", $timestamp)); //create dateobject to add a month
          $date-&gt;modify("+{$x} month"); // add the month (next month)
          $extraDays += date("t", strtotime($date-&gt;format("Y-m-d")));
          // get the days of the selected month and add them to count
          // in this case its 31 + 30 + 31 = 92
      }
  
      $days = $endOfCurrentMonth + $extraDays;
      // count everything together 16 + 92 = 108 days
  
      return date("d.m.y", $timestamp + ($tsDay*$days));
      //returning date with 108 days added.
  }
  </code></pre>
  
  <p>As a sample I call the function like:</p>
  
  <pre><code>// the timestamp is 2015-07-15
  echo getLastDeliveryDate(1436911200, true, 3); 
  // should return 2015-10-31
  </code></pre>
  
  <p>But this return <code>2015-10-30</code> and I don't know why. But 108 Days shold be <code>2015-10-31</code>. Whats going wrong here ?</p>
  
  <p>If I call </p>
  
  <pre><code>echo getLastDeliveryDate(1436911200, true, 2);
  </code></pre>
  
  <p>Its correct and gives me <code>2015-09-30</code> </p>
  
  <p>Actually I allways want the last day of the month.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Wired, if I test this here: <a href="http://ideone.com/ChrZSl" rel="nofollow">IDEONE</a> everything works fine. Im my Project it doesn't :(</p>