/*
Function written by Nelson Neoh @3/2004.
For the those who wants to utilize this code, please do not remove the this remark.
If you had done a enhancement to this code, please post the copy at Http://www.dev-club.com PHP board. Thank.
Function Usage:calendar (month,year)
*/
function Calendar ($MM, $YYYY) {
if ($MM = = "") $MM = Date ("M");
if ($YYYY = = "") $YYYY = Date ("Y");
if (Checkdate ($MM, 1, $YYYY)) {
$stringDate = Strftime ("%d%b%Y", Mktime (0,0,0, $MM, 1, $YYYY));
$days = strftime ("%d", Mktime (0,0,0, $MM +1,0, $YYYY));
$firstDay = strftime ("%w", Mktime (0,0,0, $MM, 1, $YYYY));
$lastDay = strftime ("%w", Mktime (0,0,0, $MM, $days, $YYYY));
$printDays = $days;
$preMonth = strftime ("%m", Mktime (0,0,0, $MM -1,1, $YYYY));
$preYear = strftime ("%Y", Mktime (0,0,0, $MM -1,1, $YYYY));
$nextMonth = strftime ("%m", Mktime (0,0,0, $MM +1,1, $YYYY));
$nextYear = strftime ("%Y", Mktime (0,0,0, $MM +1,1, $YYYY));
Print ("
");Print ("
P | "); Print ("
". Strftime ("%b%Y", Mktime (0,0,0, $MM, 1, $YYYY)). | Print ("
N |
");Print ("
"); Print ("
Sun |
Mon |
Tue |
Wed |
Thu |
Fri |
Sat |
");$currentDays = 1;for ($a =1; $a <=5; $a + +) {Print ("
"); $diffDays = $firstDay-$lastDay; if ($firstDay > $lastDay && $currentDays ==1 && ($diffDays <>1)) {for ($x = $lastDay; $x >=0; $x-- {$printDays = $days-$x; Print ("
$printDays | "); } for ($z =1; $z < $firstDay-$lastDay; $z + +) {print ("
| "); } for ($y = $firstDay; $y <7; $y + +) {print ("
$currentDays | "); $currentDays + +; }} elseif ($firstDay!=0 && $currentDays ==1) {for ($z =1; $z <= $firstDay; $z + +) {print ("
| "); } for ($y = $firstDay; $y <7; $y + +) {print ("
$currentDays | "); $currentDays + +; }} else {for $u =1; $u <=7 && $currentDays <= $days; $u + +) {print ("
$currentDays | "); $currentDays + +; }} print ("
");}Print ("
");
}
}
?>
The above describes the October 2010 calendar PHP generated monthly calendar code, including the October 2010 calendar content, I hope to be interested in PHP tutorial friends helpful.