note 93314 added to function.date
| From: | SeanProctor at osu1 dot php dot net | Date: | Wed, 02 Sep 2009 18:22:27 +0000 |
| Subject: | note 93314 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160169@lists.php.net to get a copy of this message | ||
For the week number for weeks starting on Sunday:
function week_of_year($month, $day, $year) {
$day_of_year = date('z', mktime(0, 0, 0, $month, $day, $year));
/* Days in the week before Jan 1. If you want weeks to start on Monday make this (x + 6) % 7 */
$days_before_year = date('w', mktime(0, 0, 0, 1, 1, $year));
$days_left_in_week = 7 - date('w', mktime(0, 0, 0, $month, $day, $year));
/* find the number of weeks by adding the days in the week before the start of the year, days up to
$day, and the days left in this week, then divide by 7 */
return ($days_before_year + $day_of_year + $days_left_in_week) / 7;
}
----
Server IP: 209.41.74.194
Probable Submitter: 72.81.55.110
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/93314
Del: integrated -- https://master.php.net/note/delete/93314/integrated
Del: useless -- https://master.php.net/note/delete/93314/useless
Del: bad code -- https://master.php.net/note/delete/93314/bad+code
Del: spam -- https://master.php.net/note/delete/93314/spam
Del: non-english -- https://master.php.net/note/delete/93314/non-english
Del: in docs -- https://master.php.net/note/delete/93314/in+docs
Del: other reasons-- https://master.php.net/note/delete/93314
Reject -- https://master.php.net/note/reject/93314
Search -- https://master.php.net/manage/user-notes.php