|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-04-11 16:39 UTC] josh dot reinert at gmail dot com
-Summary: Date("Y") for Dec returns incorrectly
+Summary: Date("Y") for certain years returns incorrectly
[2011-04-11 16:39 UTC] josh dot reinert at gmail dot com
[2011-04-11 16:58 UTC] derick@php.net
-Status: Open
+Status: Bogus
[2011-04-11 16:58 UTC] derick@php.net
[2011-04-11 17:50 UTC] josh dot reinert at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 04:00:01 2025 UTC |
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