Wrong output from mktime() in PHP
<p>I am trying to set up a php where that it sets the date up for the 1st September for each year. I am using CRON to state that everytime the date is 7th September, then the php will actually update the database for rows whose dates ae a week before that 7th September, (ist September).</p>

<p>Now the code below I tested for the 28th October and when I echo <code>$selectedDate</code> it outputs <code>2012-10-28</code> which is fine. But when I change the date to 1st September, it outputs <code>`2011-12-01</code> which is obviously incorrect. it should output `2013-09-01 as the next September date will be in 2013. Then after the Ist September date has passed in 2013, then the year should change to 2014 and etc.</p>

<p>How can I get the correct date to be outputted?</p>

<p>Below is code:</p>

<pre><code>$createDate = mktime(0,0,0,09,01,date("Y"));
$selectedDate =  date('Y-m-d', ($createDate));
</code></pre>
