Re: PHP date: ISO year = loss of hair

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Dec 14, 2007 3:02 AM, Arno Kuhl <akuhl@xxxxxxxxxxxx> wrote:
> I'm battling with getting the last week number using date(W, $unixdate). If
> the date is 30 December 2007 ($unixdate=1198965600) then date(W, $unixdate)
> returns 01. I know that according to the ISO spec, the last week of the ISO
> year has 28 December in it, so in this particular case the last week number
> of the ISO year is 52. However 30 December is in the following week, week
> 53. How do I get the correct value of 53 for 30 December 2007?
>
> I'm thinking along the lines of: if the date is greater than 28 December
> then use the week number of 28 December; then check every day between 28
> December and the date to see if a Sunday occurs and if so add one to the
> week number. It looks like it will work but seems ridiculously laboured for
> such a simple issue. Am I overlooking something obvious here - is there
> something I've missed about PHP date? Any pointers would be greatly
> appreciated.
>
> Thanks
> Arno
>

If the last week of the year is the one that has Dec. 28 in it, and
the last week number is 52, then Dec. 30 SHOULD return 1. Dec. 30 is
not in the 53rd week of 2007; it is in the first week of 2008
according to the ISO, so a week number of 1 is correct.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux