note 83564 added to function.mktime
| From: | ScottWallace at osu1 dot php dot net | Date: | Sun, 01 Jun 2008 17:34:18 +0000 |
| Subject: | note 83564 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140053@lists.php.net to get a copy of this message | ||
Here's a function I made to make an array containing all days in a given year:
<?php
# Usage: generateYearArray(int $fyear);
# $fyear is the year that you want dates for.
function generateYearArray($fyear) {
$feb = cal_days_in_month(CAL_GREGORIAN, 2, $fyear);
$daysInYear = ($feb === 29) ? 366 : 365;
$array = array();
while ($daysInYear > 0) {
$array[] = date("Y-m-d", mktime(0, 0, 0, 1, $daysInYear, $fyear));
$daysInYear--;
}
sort($array);
return $array;
}
?>
Example:
generateYearArray(2008);
should return an array like:
Array(
[0] => "2008-01-01",
[1] => "2008-01-02",
...
[363] => "2008-12-29",
[364] => "2008-12-30",
[365] => "2008-12-31"
)
This function is released into the public domain.
----
Server IP: 208.69.120.35
Probable Submitter: 70.122.91.158
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- https://master.php.net/note/edit/83564
Del: integrated -- https://master.php.net/note/delete/83564/integrated
Del: useless -- https://master.php.net/note/delete/83564/useless
Del: bad code -- https://master.php.net/note/delete/83564/bad+code
Del: spam -- https://master.php.net/note/delete/83564/spam
Del: non-english -- https://master.php.net/note/delete/83564/non-english
Del: in docs -- https://master.php.net/note/delete/83564/in+docs
Del: other reasons-- https://master.php.net/note/delete/83564
Reject -- https://master.php.net/note/reject/83564
Search -- https://master.php.net/manage/user-notes.php