Re: Issue with 'W' in the date() function?

From: Date: Tue, 03 Feb 2004 15:39:26 +0000
Subject: Re: Issue with 'W' in the date() function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176682@lists.php.net to get a copy of this message
William Bailey wrote:
Hi all,
    Can somebody please explain this for me...
wb@vaio:/usr/home/wb [11]-> php <?php $time = strtotime('now -5 weeks'); printf("\n\n%s is in week %d of the year %d\n\n", date('Y-m-d', $time), date('W', $time), date('Y', $time)); ?> ^D 2003-12-30 is in week 1 of the year 2003 wb@vaio:/usr/home/wb [12]->
    Why does it return 1 as the week of the year for that date?
Because week 1 is defined as the first week with four or more days in the new year. Therefore, working backwards, the 29th-31st are also in week 1 in 2004. Mike

« previous php.general (#176682) next »