Date: 06/20/01
- Next message: Wez Furlong: "Re: [PHP-DEV] Memory overwriting problem in CVS"
- Previous message: antipode <email protected>: "[PHP-DEV] Bug #11569: session_register() not working after session_unset(); session_destroy();"
- Next in thread: derick <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Maybe reply: derick <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Maybe reply: derick <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Maybe reply: cmv <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Maybe reply: cmv <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ID: 11555
User Update by: martin <email protected>
Status: Open
Bug Type: Feature/Change Request
Operating system: any
PHP Version: 4.0.5
Description: date() format addition
i live in sweden, where displaying weeknumbers in calendars of any sort is common. the
following code does the work, tho i'd be very happy if it could be supported to be returned
from the date() function.
switch(date("w",mktime(0,0,0,$mon,$daycnt+1,$year))) {
case 1: $daysub=0; break;
case 2: $daysub=1; break;
case 3: $daysub=2; break;
case 4: $daysub=3; break;
case 5: $daysub=4; break;
case 6: $daysub=5; break;
case 0: $daysub=6; break;
}
$weeknumber=round((date("z", mktime(0,0,0, date("m"),date("d")+1-$daysub,date("Y")))+7)/7);
if($weeknumber==53) {
//some years have 53 weeks & some 52
//so we check next weeks weeknumber, if its 1 this is week 53, otherwise, this is week 1.
switch(date("w",mktime(0,0,0,date("m"),date("d")+8,date("Y")))) {
case 1: $daysub=0; break;
case 2: $daysub=1; break;
case 3: $daysub=2; break;
case 4: $daysub=3; break;
case 5: $daysub=4; break;
case 6: $daysub=5; break;
case 0: $daysub=6; break;
}
$tmpweeknumber=round( (date("z", mktime(0,0,0, date("m"), date("d")+8-$daysub, date("Y")))+7)/7);
if($tmpweeknumber==1) $weeknumber=53;
else $weeknumber=1;
}
Previous Comments:
---------------------------------------------------------------------------
[2001-06-19 05:41:56] martin <email protected>
i live in sweden, where displaying weeknumbers in calendars of any sort is common. the following code does the work, tho i'd be very happy if it could be supported to be returned from the date() function.
the algorithm is (mondaynumber+7)/7
where mondaynumber is the day of the year of the monday of the current year
switch(date("w")) {
case 1: $daysub=0; break;
case 2: $daysub=1; break;
case 3: $daysub=2; break;
case 4: $daysub=3; break;
case 5: $daysub=4; break;
case 6: $daysub=5; break;
case 0: $daysub=6; break;
}
$weeknumber=(date ("z", mktime(0,0,0, date("m"), date("d")-$daysub, date("Y")) )+7)/7;
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=11555
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Wez Furlong: "Re: [PHP-DEV] Memory overwriting problem in CVS"
- Previous message: antipode <email protected>: "[PHP-DEV] Bug #11569: session_register() not working after session_unset(); session_destroy();"
- Next in thread: derick <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Maybe reply: derick <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Maybe reply: derick <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Maybe reply: cmv <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Maybe reply: cmv <email protected>: "[PHP-DEV] Bug #11555 Updated: date() format addition"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

