RE: [PHP] PHP date: ISO year = loss of hair
| From: | Arno Kuhl | Date: | Fri, 14 Dec 2007 15:55:46 +0000 |
| Subject: | RE: [PHP] PHP date: ISO year = loss of hair | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265876@lists.php.net to get a copy of this message | ||
-----Original Message-----
From: tedd [mailto:tedd.sperling@gmail.com]
Sent: 14 December 2007 04:50
To: arno@dotcontent.net; php-general@lists.php.net
Cc: Arno Kuhl
Subject: Re: [PHP] PHP date: ISO year = loss of hair
At 10:02 AM +0200 12/14/07, Arno Kuhl wrote:
>I'm battling with getting the last week number using date(W,
>$unixdate). If the date is 30 December 2007 ($unixdate=1198965600)
Not accordingly to my calculations -- try it:
http://webbytedd.com/c/unix-time/
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
The standard date calculations don't show a week number. If you use
1198965600 as the decimal seconds in your form you'll see that the human
date is 30 December 2007 12:00:00. But if you try date(W, 1198965600) you'll
get a value of 01 for the week number. This conforms to the ISO date
standards, but it doesn't help much when you're trying to calculate the real
week number. Luckily (?) this year is a bit of a fluke or I might not have
detected this error in my script - the next time it happens is in 2012. I
fixed it by taking the long code route: use the week number for December 28
yyyy if the date is > December 28 yyyy, check for a sunday between December
28 and the date and increment the week number. I now get week 53 for 30
December 2007.
Cheers
Arno