Edit report at http://bugs.php.net/bug.php?id=54505&edit=1
ID: 54505 Updated by: der...@php.net Reported by: josh dot reinert at gmail dot com Summary: Date("Y") for certain years returns incorrectly -Status: Open +Status: Bogus Type: Bug Package: Date/time related Operating System: Windows 7 PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Uh, what are you trying to do here? The year is the ISO-year, and the W an ISO-week number. Please read up on how that works here: http://en.wikipedia.org/wiki/ISO_year#Relation_with_the_Gregorian_calendar Previous Comments: ------------------------------------------------------------------------ [2011-04-11 16:39:32] josh dot reinert at gmail dot com Trying to modify the summary since it affects the year not just the month ------------------------------------------------------------------------ [2011-04-11 16:35:45] josh dot reinert at gmail dot com 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 this bug report at http://bugs.php.net/bug.php?id=54505&edit=1