note 73217 added to function.date
| From: | mybenchmarkidatyahoodotcom at osu1 dot php dot net | Date: | Tue, 13 Feb 2007 18:55:13 +0000 |
| Subject: | note 73217 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123329@lists.php.net to get a copy of this message | ||
here is a function I wrote that was useful for a calendar application I was using.
It returns an array of the valid dates between two parameter dates. enjoy.
<?
function DatesBetween($startDate, $endDate){
// get the number of days between the two given dates.
$days = (strtotime($endDate) - strtotime($startDate)) / 86400 + 1;
$startMonth = date("m", strtotime($startDate));
$startDay = date("d", strtotime($startDate));
$startYear = date("Y", strtotime($startDate));
$dates;//the array of dates to be passed back
for($i=0; $i<$days; $i++){
$dates[$i] = date("n/j/Y", mktime(0, 0, 0, $startMonth , ($startDay+$i), $startYear));
}
return $dates;
}
?>
example: $dates = DatesBetween("2/27/2007","3/3/2007")
Array ( [0] => 2/27/2007 [1] => 2/28/2007 [2] => 3/1/2007 [3] => 3/2/2007 [4] =>
3/3/2007 )
----
Server IP: 64.71.164.2
Probable Submitter: 67.134.242.3
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/73217
Del: integrated -- https://master.php.net/note/delete/73217/integrated
Del: useless -- https://master.php.net/note/delete/73217/useless
Del: bad code -- https://master.php.net/note/delete/73217/bad+code
Del: spam -- https://master.php.net/note/delete/73217/spam
Del: non-english -- https://master.php.net/note/delete/73217/non-english
Del: in docs -- https://master.php.net/note/delete/73217/in+docs
Del: other reasons-- https://master.php.net/note/delete/73217
Reject -- https://master.php.net/note/reject/73217
Search -- https://master.php.net/manage/user-notes.php