Last six months list in PHP
<p>I need the previous six months list and am using the following code for that.</p>

<pre><code>for ($i=6; $i &gt;= 1; $i--) {
  array_push($months, date('M', strtotime('-'.$i.' Month')));
}

print_r($months);
</code></pre>

<p>Its gives the wrong output as follows</p>

<pre><code>Array
(
    [0] =&gt; 'Dec'
    [1] =&gt; 'Dec'
    [2] =&gt; 'Jan'
    [3] =&gt; 'Mar'
    [4] =&gt; 'Mar'
    [5] =&gt; 'May'
)
</code></pre>

<p>It must be</p>

<pre><code>Array
(
    [0] =&gt; 'Nov'
    [1] =&gt; 'Dec'
    [2] =&gt; 'Jan'
    [3] =&gt; 'Feb'
    [4] =&gt; 'Mar'
    [5] =&gt; 'Apr'
)
</code></pre>

<p>Where am i wrong. Help please</p>
