note 51106 added to function.date

From: Date: Sun, 20 Mar 2005 03:41:52 +0000
Subject: note 51106 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-86702@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51106 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51106&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51106&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51106&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51106&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51106&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51106&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86702) next »