note 51106 deleted from function.date by derick

From: Date: Sun, 11 Jun 2006 11:33:03 +0000
Subject: note 51106 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-114223@lists.php.net to get a copy of this message
Note Submitter: duh_cabbage at paradise dot net dot nz ---- I found this useful for working out the week of the year if you want to for example find the third Tuesday of the year, using the date("w") function could return 3 or 4 for the correct day. This function does not seem to count week one as the first 7 days of the year, but instead the first 4-7 days of the year, dependent on the start day of the year. Using <?php $weekofyear = (date("z", $stamp) - (date("z", $stamp)%7))/7 + 1; ?> seems to return the week number by counting each week through the day number of the year and counting 7 per week so week 1 is days 1-7, week 2 is days 8-14 etc. Subtracting the remainder (date("z", $stamp)%7) tidies up the output by ensuring no decimals remain.

« previous php.notes (#114223) next »