RE: PHP date: ISO year = loss of hair

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

 



-----Original Message-----
From: tedd [mailto:tedd.sperling@xxxxxxxxx] 
Sent: 14 December 2007 04:50
To: arno@xxxxxxxxxxxxxx; php-general@xxxxxxxxxxxxx
Cc: Arno Kuhl
Subject: Re:  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

-- 
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