note 68269 added to function.date
| From: | AlvinDelagon at osu1 dot php dot net | Date: | Thu, 20 Jul 2006 09:48:11 +0000 |
| Subject: | note 68269 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114964@lists.php.net to get a copy of this message | ||
Here's a function that takes the year as input and returns an array or dates that are mondays.
(It can be used for generating weekly reports just like I did)
function getMondays($year) {
$newyear = $year;
$week = 0;
$day = 0;
$mo = 1;
$mondays = array();
$i = 1;
while ($week != 1) {
$day++;
$week = date("w", mktime(0, 0, 0, $mo,$day, $year));
}
array_push($mondays,date("r", mktime(0, 0, 0, $mo,$day, $year)));
while ($newyear == $year) {
$test = strtotime(date("r", mktime(0, 0, 0, $mo,$day, $year)) . "+" . $i .
" week");
$i++;
if ($year == date("Y",$test)) {
array_push($mondays,date("r", $test));
}
$newyear = date("Y",$test);
}
return $mondays;
}
----
Server IP: 66.163.161.117
Probable Submitter: 58.71.23.228
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/note/edit/68269
Del: integrated -- http://master.php.net/note/delete/68269/integrated
Del: useless -- http://master.php.net/note/delete/68269/useless
Del: bad code -- http://master.php.net/note/delete/68269/bad+code
Del: spam -- http://master.php.net/note/delete/68269/spam
Del: non-english -- http://master.php.net/note/delete/68269/non-english
Del: in docs -- http://master.php.net/note/delete/68269/in+docs
Del: other reasons-- http://master.php.net/note/delete/68269
Reject -- http://master.php.net/note/reject/68269
Search -- http://master.php.net/manage/user-notes.php