}
function show_date_form($name, $date = null) {
+ $past = 60;
+ $future = 60;
echo "<select name=\"$name\">\n";
- $now = time();
+ $now = date('Y-m-d', time());
+ list($y, $m, $d) = explode('-', $now);
+ $today = mktime(0, 0, 0, $m, $d, $y);
if (isset($date)) {
list($y, $m, $d) = explode('-', $date);
$then = mktime(0, 0, 0, $m, $d, $y);
- option($name, $date, date('l j F Y', $then), $date);
+ if ($then < $today - 86400 * $past || $then > $today + 86400 * $future) {
+ option($name, $date, date('l j F Y', $then), $date);
+ }
}
- for ($i = 0; $i < 60; $i++) {
- $then = $now + 86400 * $i;
+ else $date = $now;
+ for ($i = -$past; $i < $future; $i++) {
+ $then = $today + 86400 * $i;
option($name, date('Y-m-d', $then), date('l j F Y', $then), $date);
}
echo "</select>\n";