PHPBuilder - Calender Code Lite



RSS Twitter
Snippets Calendars Dates

Calender Code Lite

by: Tim Rawlinson
|
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>"

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Tim Rawlinson

Comment:



Comment:

(Maximum characters: 1200). You have characters left.