From: Operating system: Windows 7 PHP version: 5.3.6 Package: Date/time related Bug Type: Bug Bug description:Date("Y") for Dec returns incorrectly
Description: ------------ I am actually running PHP 5.3.5 on Apache 2.2 on Windows 7 as my development machine. php.net states: W ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) I have a calender class that I created that lists the weeks of the year for a given month. For certain years when January 1st is not on Sunday or Monday the date function is returning that it is still on the first week of the year where if the weeks start on Monday it should be returning the last week of the previous year. This then offsets the rest of the year. I noticed it when I had a Dec. with week 54. Test script: --------------- for ($i=2000; $i<2040; $i++){ //---- Week of the Year $WoY = (int) date("W", mktime(0, 0, 0, 1, 1, $i)); //---- Day of Jan 1st $DoM = date("l", mktime(0, 0, 0, 1, 1, $i)); //---- If the week is 1 then the day must be either Sunday or Monday; otherwise we are still in the previous year if ($WoY == 1 && !($DoM == "Monday" || $DoM == "Sunday")) print "$DoM Jan 1, $i is on week $WoY\n<BR>\n"; } Expected result: ---------------- <BLANK> Actual result: -------------- Tuesday Jan 1, 2002 is on week 1 Wednesday Jan 1, 2003 is on week 1 Thursday Jan 1, 2004 is on week 1 Tuesday Jan 1, 2008 is on week 1 Thursday Jan 1, 2009 is on week 1 Tuesday Jan 1, 2013 is on week 1 Wednesday Jan 1, 2014 is on week 1 Thursday Jan 1, 2015 is on week 1 Tuesday Jan 1, 2019 is on week 1 Wednesday Jan 1, 2020 is on week 1 Wednesday Jan 1, 2025 is on week 1 Thursday Jan 1, 2026 is on week 1 Tuesday Jan 1, 2030 is on week 1 Wednesday Jan 1, 2031 is on week 1 Thursday Jan 1, 2032 is on week 1 Tuesday Jan 1, 2036 is on week 1 Thursday Jan 1, 2037 is on week 1 Wednesday Jan 1, 2039 is on week 1 -- Edit bug report at http://bugs.php.net/bug.php?id=54505&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54505&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54505&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54505&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54505&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54505&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54505&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54505&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54505&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54505&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54505&r=support Expected behavior: http://bugs.php.net/fix.php?id=54505&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54505&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54505&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54505&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54505&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54505&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54505&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54505&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54505&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54505&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54505&r=mysqlcfg