PX : code

Calendar Class by Jason
Download this code


<?

if (!$month)    { $month = date("m"); };
if (!$year)     { $year = date("Y"); };
if (!$day)      { $day = date("d"); };


include("./calendar.inc");
$myCal = new Calendar;
printf ($myCal->genCalendar($month,$day,$year));

?>




<?php
class Calendar
{
        function 
genCalendar($month,$day,$year)
        {
                
$base_date mktime(0,0,0,$month,1,$year);
                
$firstDayOfMonth date("w",$base_date);
                
$stopMe $firstDayOfMonth 1;

                
$daysOfWeek = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

                for (
$lastday 31$lastday 27$lastday--)
                {
                        
$monsta checkdate($month,$lastday,$year);
                        if (
$monsta)
                        {
                                break;
                        }
                }
                print 
"<center>";
                print 
"<B>$month - $day - $year</B><BR><BR>";
                print 
"<table border=5 cellspacing=0>";
                print 
"<TR>";
                for (
$x 0$x 7$x++)
                {
                        print 
"<TD width=90 bgcolor=#c0c0c0 valign=middle align=center><font face=\"verdana, arial\" size-1>$daysOfWeek[$x]</font></td>";
                }
                print 
"</tr>";

                print 
"<tr>";
                for (
$z 0$z <  7$z++)
                {
                        if ( 
$z $firstDayOfMonth )
                        {
                                print 
"<TD bgcolor=#c0c0c0></TD>";
                        }
                        else
                        {
                                break;
                        }
                }
                for (
$z 1$z $stopMe $z++)
                {
                        print 
"<TD>$z</TD>";
                }
                print 
"</tr>\n";
                
$hold $z;
                
$hold--;

                for (;
$z <= $lastday$z++)
                {
                        print 
"<td>$z</td>";
                        
$wood $z $hold;
                        if ( 
$wood == 0)
                        {
                                print 
"</TR>\n<TR>";
                        }
                }
                print 
"</table>";
                print 
"</center>";
        }
}
?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.