is dynamic, it shows the selected year +/- 5 years. - A light version, for embedding into existing pages is available. (http://www.mind.lu/~yg/stuff/) Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) */ $CurDate = getdate(); //gets the server current date. if (checkdate($HTTP_GET_VARS['month'],1,$HTTP_GET_VARS['year']) == NULL) { $YearToShow = $CurDate['year']; // $YearToShow = $CurDate['year']; $MonthToShow = $CurDate['mon']; // $MonthToShow = $CurDate['mon']; } else { if (checkdate($HTTP_GET_VARS['month'],1,$HTTP_GET_VARS['year']) == false) { $YearToShow = $CurDate['year']; $MonthToShow = $CurDate['mon']; } else { $YearToShow = $HTTP_GET_VARS['year']; $MonthToShow = $HTTP_GET_VARS['month']; if ( ($YearToShow < 1902) || ($YearToShow > 2037) ) { $YearToShow = $CurDate['year']; $MonthToShow = $CurDate['mon']; } } } // This checks to see if the current day will be displayed. If it is make the background a color. if ( ($YearToShow == $CurDate['year']) && ($MonthToShow == $CurDate['mon']) ) { $DayToShow = $CurDate['mday']; } // This checks to see how many days are in the month in question. $NumberOfDays = date(t,mktime(0,0,0,$MonthToShow+1,0,$YearToShow,-1)); // This section converts the month number to the month name. $MonthNames = array(1=>'January','February','March','April','May','June','July','August','September','October','November','December'); //$Years = array('1998','1999','2000','2001','2002','2003','2004','2005'); $Years = array($YearToShow-5,$YearToShow-4,$YearToShow-3,$YearToShow-2,$YearToShow-1,$YearToShow,$YearToShow+1,$YearToShow+2,$YearToShow+3,$YearToShow+4,$YearToShow+5); // Sets up the href if ($MonthToShow == 12) { $pmon = ($MonthToShow - 1); $pyear = ($YearToShow); $nmon = (1); $nyear = ($YearToShow + 1); } else { if ($MonthToShow == 1) { $pmon = (12); $pyear = ($YearToShow - 1); $nmon = ($MonthToShow + 1); $nyear = ($YearToShow); } else { $pmon = ($MonthToShow - 1); $pyear = ($YearToShow); $nmon = ($MonthToShow + 1); $nyear = ($YearToShow); } } echo <<
$MonthNames[$MonthToShow] $YearToShow << previous      next >>
Month\nYear
Sunday Monday Tuesday Wednesday Thursday Friday Saturday EOT; $FirstDayOfWeek = date(l,mktime(0,0,0,$MonthToShow,1,$YearToShow)); // This section ofsets the first day of the month so it matches the day of week. switch ($FirstDayOfWeek) { case 'Monday': $offset = 1; break; case 'Tuesday': $offset = 2; break; case 'Wednesday': $offset = 3; break; case 'Thursday': $offset = 4; break; case 'Friday': $offset = 5; break; case 'Saturday': $offset = 6; break; default: $offset = 0; } // this covers the first few empty days. if ($offset > 0) { print ""; echo str_repeat(" ",$offset); } // This section is to Allow the first day of the week to be sunday and also. // to make sure that the table prints out right. for ($i=1; $i <= $NumberOfDays; $i++) { $DayOfWeek = date(l,mktime(0,0,0,$MonthToShow,$i,$YearToShow)); if($DayOfWeek == 'Sunday') { print ""; } if ($i != $DayToShow) { print "$i"; } else { print "$i"; } if($DayOfWeek == 'Saturday') { print "\n"; } } // This section will fill in the blank spaces. // The first part covers Feb. if ( ( ($offset == 5) && ($NumberOfDays > 30) ) || ( ($offset == 6) && ($NumberOfDays > 29) ) ) { if (42-$NumberOfDays-$offset > 0) { echo str_repeat(" \n",42-$NumberOfDays-$offset); } print "\n"; } elseif ( ($NumberOfDays != 28) || ($offset > 0) ) { if (35-$NumberOfDays-$offset > 0) { echo str_repeat(" \n",35-$NumberOfDays-$offset); print "\n"; } } echo << EOT; ?>