unexpected result when adding months to a date
<p>I need to add 3 months to a date until passing a certain date:</p>

<pre><code>  $next_dt = date('Y-m-d H:i:s', strtotime('2015-12-31 00:00:00'));
  while($next_dt &lt;= '2016-11-07 00:00:00'){
       $next_dt = date('Y-m-d H:i:s', strtotime("+3 months",strtotime($next_dt)));      
  }
</code></pre>

<p>the result of this addition is 2017-01-01 00:00:00
while i am expecting the result to be 2016-12-31 00:00:00</p>

<p>if i am adding 12 months at once the result is correct</p>

<pre><code>$orig_dt = date('Y-m-d H:i:s', strtotime('2015-12-31 00:00:00'));
$next_dt = date('Y-m-d H:i:s', strtotime("+12 months", strtotime($orig_dt)));
</code></pre>

<p>but i cannot know in advance how many months i will need to add</p>

<p>what shall I do?</p>