<?
function makecal($stmonth, $styear) {
###################################
## define variables-little cleaner
## than mucking over the code to
## change stuff
##
$face = "verdana"; ## font face for all text
$size = "1"; ## font size for all text
$height = "22"; ## cell height
$width = "22"; ## cell width
$todaycolor = "#CC0000"; ## font color for the current date
$inmonthface = "#000000"; ## font color for days in the display month
$outmonthface = "#666666"; ## font color for days not in the display month
$inbgcolor = "#FFFFCC"; ## cell bgcolor for days in the display month
$outbgcolor = "#FFCCFF"; ## cell bgcolor for days not in display month
###################################
## make workie code stuph
##
$stdate = mktime(0,0,0,$stmonth,1,$styear);
$startdate = $currdate = mktime(0,0,0,$stmonth,1 - date("w", mktime(0,0,0,$stmonth,1,$styear)),$styear);
$enddate = mktime(0,0,0,date("m",$stdate) + 1,7 - date("w", mktime(0,0,0,$stmonth + 1,0,$styear)),$styear);
echo "<table border=1 cellpadding=1 cellspacing=0>\n";
echo "<tr>\n<th colspan=7 height=\"$height\"><font face=\"$face\" size=\"$size\">" . date("F",$stdate) . " " . date
("Y",$stdate) . "</th>\n</tr>\n";
echo "<tr>\n<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Su</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Mo</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Tu</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">We</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Th</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Fr</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Sa</th>\n</tr>\n";
$i=0;
while ($currdate < $enddate) {
echo "<tr>\n";
for ($c = 0; $c < 7; $c++) {
if (date("m",$stdate) == date("m",$currdate)) {
$bgcolor = $inbgcolor;
} else {
$bgcolor = $outbgcolor;
}
if (date("d",$currdate) == date("d") && date("m",$currdate) == date("m") && date("Y",$currdate) == date
("Y")) {
$fcolor = $todaycolor;
} elseif (date("m",$currdate) == date("m",$stdate) && date("Y",$currdate) == date("Y",$stdate)) {
$fcolor = $inmonthface;
} else {
$fcolor = $outmonthface;
}
echo "<td align=\"center\" height=\"$height\" width=\"$width\" valign=\"middle\" bgcolor=\"$bgcolor\"><font
face=\"$face\" size=\"$size\"
color=\"$fcolor\">";
echo date ("j",$currdate);
echo "</font></td>\n";
$i++;
$currdate = mktime(0,0,0,date("m",$startdate),date("d",$startdate) + $i,date("Y",$startdate));
}
echo "</tr>\n";
}
echo "</table>";
}
###################################
## example usage
##
echo "<html><head></head><body bgcolor=\"#ffffff\">\n\n";
echo "<form action=cal.php3 method=post>\n";
echo "<select name=stmonth>\n";
echo "<option>1\n";
echo "<option>2\n";
echo "<option>3\n";
echo "<option>4\n";
echo "<option>5\n";
echo "<option>6\n";
echo "<option>7\n";
echo "<option>8\n";
echo "<option>9\n";
echo "<option>10\n";
echo "<option>11\n";
echo "<option>12\n";
echo "</select>\n";
echo "<select name=styear>\n";
echo "<option>1999\n";
echo "<option>2000\n";
echo "<option>2001\n";
echo "<option>2002\n";
echo "<option>2003\n";
echo "<option>2029\n";
echo "</select>\n";
echo "<input type=submit value=\"show cal\">\n<input type=submit name=source value=\"view source\">\n</form>\n\n";
echo "<BR>\n\n";
if ($stmonth && $styear && empty($source)) {
echo makecal($stmonth,$styear);
} elseif (empty($source)) {
echo makecal(date("m"),date("Y"));
} else {
echo "<code><font size=1>\n";
show_source("cal.php3");
echo "</font></code>\n";
}
echo "</body>\n</html>";
?>
Calendars to choose a range of dates , reservation events ... Categories : PHP , Calendar , Java Script , Date Time Shows the current time as a PNG-image. This script does not use the GD
library. You can use it as a benchmark (because it's slow), or as a quick
reference for implementing a simple PNG-file generator. Categories : Graphics , Zlib , Calendar , PHP , Date Time pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP , Date Time , Calendar , PHP Classes PHP Calendar Web App Categories : PHP , Databases , MySQL , Date Time , Calendar table calendar pretty much does what cal(1) does - prints out a calendar.
Categories : Date Time , PHP , Calendar PHP Calendar Categories : PHP , Calendar , Date Time , Java Script , CSS Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example. Categories : PHP , Date Time , PHP Classes , Calendar Customizable Calendar Class Categories : HTML and PHP , Date Time , PHP , PHP Classes , Calendar Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June). Categories : Calendar , Date Time , PHP Monthly and Daily Upcoming Events calendar. Categories : Date Time , PostgreSQL , PHP , Calendar , Databases This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time. Categories : PHP , Calendar , Date Time , HTML and PHP Calendar, Kalender, date, time, day, month, year Categories : PHP , Date Time , Calendar Simple PHP control CSS Calendar Categories : PHP , HTML and PHP , Calendar , Date Time , CSS Calendar using Date function Categories : HTML and PHP , PHP , Date Time , Calendar A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed. Categories : Date Time , PHP , Complete Programs , Calendar
James Whiddon wrote : 169
oops. i forgot to add the \ before the " starting at line
32 after the $face variable. sorry.
Paul Meagher wrote : 280
This calender does not appear to work correctly as of
March 2000. Might be some type of leap year problem.
Buddy Fortner wrote : 293
I can`t get it to work either. should it copy and paste
"as is", or is there some edits to make?
James Whiddon wrote : 374
What types of problems are you having? It seems to be working on my
machine.
Rod wrote : 385
Where is cal.php3??????
pierre-yves lemaire wrote : 429
It does not work after march 2000, Did someone find
out the problem ?
It keeps giving me january of 1999 when I try anything
after march 2000.
py
Dimitrios Zinas wrote : 830
It works ok just the list writes 1999.
If you want update e-mailme...