PHP calendar first week of the year displays wrong year
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/12266310/php-advance-weekly-calendar-one-week">Php.Advance weekly calendar one week</a>  </p>
</blockquote>



<p>I have written a script that displays a calendar week by week that the user can chose to go back or forward a week at a time.  Everything works great except the first week of every year still displays the wrong year and the 31st December shows as 02/01.  It seems that only week 1 is affected, the days are correct again in week and onwards</p>

<pre><code>&lt;?
if(isset($_POST['add_week'])){
     $last_week_ts = strtotime($_POST['last_week']);
     $display_week_ts = $last_week_ts + (3600 * 24 * 7);
} else if (isset($_POST['back_week'])) {
     $last_week_ts = strtotime($_POST['last_week']);
     $display_week_ts = $last_week_ts - (3600 * 24 * 7);
} else {
    $display_week_ts = floor(time() / (3600 * 24)) * 3600 * 24;
}

    $week_start = date('d-m-Y', $display_week_ts);
    $week_number = date("W", $display_week_ts);
    $year = date("Y", $display_week_ts);

echo $week_start.' '.$week_number.' '.$year;
?&gt;

&lt;table name="week"&gt;
    &lt;tr&gt;
&lt;?
for($day=1; $day&lt;=7; $day++)
{
    echo '&lt;td&gt;';
    echo date('d-m-Y', strtotime($year."W".$week_number.$day))." | \n";
    echo '&lt;/td&gt;';
}
?&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;form name="move_weeks" method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
&lt;input type="hidden" name="last_week" value="&lt;? echo $week_start; ?&gt;" /&gt;
&lt;td colspan="7"&gt;&lt;input type="submit" name="back_week" value="back_week" /&gt;&lt;input type="submit" name="add_week" value="add_week" /&gt;
&lt;/td&gt;
&lt;/form&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>Any help will be appreciated</p>
