Hi, Try it with 28 December instead of 31 December.
From http://en.wikipedia.org/wiki/ISO_week_date
The last week of the ISO year is the week before week 01; in accordance with the symmetry of the definition, equivalent definitions are: - the week with the year's last Thursday in it - the week with December 28 in it - the last week with the majority (four or more) of its days in the ending year - the week starting with the Monday in the period 22 - 28 December - the week with the Thursday in the period 25 - 31 December - the week ending with the Sunday in the period 28 December - 3 January - If 31 December is on a Monday, Tuesday, or Wednesday, it is in week 01, otherwise in week 52 or 53. Best Regards, Ducarom On 9/13/06, Arno Kuhl <akuhl@xxxxxxxxxxxx> wrote:
I hope someone can help with this. I'm trying to find the week number of the last week of the year. I have the following code snippet: $lastday = strtotime("31 December ".$year); $lastdate = date("Y-m-d", $lastday); // for testing $lastweek = date(W, $lastday); I put the $lastdate line in because I was convinced that $lastday must be wrong, but it's correct! When $year is 2000 I get an expected $lastweek of 52. When $year is 2001, 2002, or 2003 the $lastweek is 01! When $year is 2004 $lastweek is 53. When $year is 2005 $lastweek is 52. I haven't checked further than 2005. Why do I get the weird lastweek values for 2001, 2002, and 2003? I'm using PHP 4.3.4 on Win2000. Arno -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php