/*
函数由 Nelson Neoh @3/2004 编写。
想要使用此代码的人,请不要删除此备注。
如果您对此代码进行了任何增强,请将副本发布在 http://www.dev-club.com PHP 板上。 谢谢。
函数用法:日历(月,年)
*/
函数日历($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 print("");
$diffDays = $firstDay-$lastDay;
if($firstDay>$lastDay && $currentDays ==1 && ($diffDays1)){
for($x=$lastDay;$x>=0;$x--){
$printDays = $days-$x;
print("$printDays | ");
}
for($z=1;$z print(" | ");
}
for($y=$firstDay;$y print("$currentDays | ");
$currentDays ;
}
} elseif($firstDay!=0 && $currentDays==1){
for($z=1;$z print(" | ");
}
for($y=$firstDay;$y print("$currentDays | ");
$currentDays ;
}
} else {
for($u=1;$u print("$currentDays | ");
$currentDays ;
}
}
print("
");
}
print("
print ("
P | ");
print("".strftime("%b % Y",mktime (0,0,0,$MM,1,$YYYY))." | ");
print("N |
");
print("");
print("周日 |
周一 |
周二 |
周三 | 星期四 |
星期五 |
星期六 |
"); $currentDays = 1; for($a= 1;$a print("") ; $diffDays = $firstDay-$lastDay; if($firstDay>$lastDay && $currentDays ==1 && ($diffDays1)){ for($x=$lastDay; $x>=0;$x--){ $printDays = $days-$x; print("$printDays | "); } for ($z=1;$z print(" | "); } for($y=$firstDay; $y print("$currentDays | "); $currentDays ; } } elseif($firstDay!=0 && $ currentDays==1){ for($z=1;$z print(" | "); } for($y=$firstDay;$y print("$currentDays | "); $currentDays ; } } else { for($u=1;$u print("$currentDays | "); $ currentDays ; } } print(""); } print("
"); }}?>