#native_company# #native_desc#
#native_cta#

Calender Code Lite

By Tim Rawlinson
on June 4, 2002

Version: 1.2

Type: Sample Code (HOWTO)

Category: Calendars/Dates

License: GNU General Public License

Description: The is the shortest code I could come up with for displaying a calender. It works on PHP Version 4.1.2. I don’t know about anything else.

	echo "<table border=1><tr>";
	if (empty($Year)) $Year =  date("Y");
	if (empty($Month)) $Month =  date("n");
	$DaysInMonth = date("t",mktime ( 0, 0, 0, $Month, 1, $Year));
	$DayOffset = date("w",mktime ( 0, 0, 0, $Month, 1, $Year))-1;
	if ($DayOffset<0) $DayOffset+=7;
	for ($i = 1;$i <= $DayOffset; $i++) echo "<td></td>";
	for ($i = 1;$i <= $DaysInMonth; $i++){
		if ($i==date("j") && $Month==date("n") && $Year==date("Y")) echo "<td><b><u>$i</u></b></td>";
		else echo "<td>$i</td>";
		if (((($i + $DayOffset) % 7) == 0) && ($i <> $DaysInMonth)) echo "</tr><tr>";
	}
	echo "</td></tr></table>"