note 12884 deleted from function.date by jimw
| From: | jimw@php.net | Date: | Fri, 02 Nov 2001 01:08:13 +0000 |
| Subject: | note 12884 deleted from function.date by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20082@lists.php.net to get a copy of this message | ||
I wanted to get all the dates of the next two year, which are on a tuesday, thurstday or sunday.
(for a travel-site, the plane only flys on that days). I couldn't find such a function in here,
so, because the notes helped me a lot, I post my solution right here.
The dates are printed in a drop-down menu in the format dd/mm/yyyy. The 3 good days are in an array:
vluchtInfo[1], [2] & [3], taken from an MySQL database.
print "<td width=\"29%\" class=\"tekst\"
bgcolor=\"#FFFFB7\"><select name=\"datum$vluchtInfo[0]\"
size=\"1\">\n";
for ($year = date("Y"); $year < (date("Y") + 2); $year++) {
if ($year == date("Y")) {$monthBegin = date("n"); } else {$monthBegin = 1;}
for ($month = $monthBegin; $month < 13; $month++) {
if ($year == date("Y") && $month == date("n")) {$dayBegin =
date("d"); } else {$dayBegin = 1;}
$daysInMonth = date("t", $month);
for ($day = $dayBegin; $day < ($daysInMonth + 1); $day++) {
if (date ("D", mktime (0,0,0,$month,$day,$year)) == $vluchtInfo[1] || date
("D", mktime (0,0,0,$month,$day,$year)) == $vluchtInfo[2] || date ("D", mktime
(0,0,0,$month,$day,$year)) == $vluchtInfo[3]) {
print "<option
value=\"$day/$month/$year\">$day/$month/$year</option>\n";
}
}
}
}
print "</select></td>\n";
I hope it will help some of you guys.