- /**
- PHP automatically generate monthly calendar
- Link:bbs.it-home.org 2013-3-7
- */
- 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 ("
- Print ("
- Print ("
- Print ("
- Print ("
- $diffDays = $firstDay-$lastDay;
- }
- }
- $currentDays + +;
- }
- $currentDays + +;
- $currentDays + +;
- }
- if ($firstDay > $lastDay && $currentDays ==1 && ($diffDays <>1)) {
- for ($x = $lastDay; $x >=0; $x--) {
- $printDays = $days-$x;
- Print ("
- for ($z =1; $z < $firstDay-$lastDay; $z + +) {
- Print ("
- for ($y = $firstDay; $y <7; $y + +) {
- Print ("
- }
- } elseif ($firstDay!=0 && $currentDays ==1) {
- for ($z =1; $z <= $firstDay; $z + +) {
- Print ("
- for ($y = $firstDay; $y <7; $y + +) {
- Print ("
- }
- } else {
- for ($u =1; $u <=7 && $currentDays <= $days; $u + +) {
- Print ("
- }
- }
- Print ("
");
P | ");
". Strftime ("%b%Y ", Mktime (0,0,0, $MM, 1, $YYYY))." | ");
N |
");
");
Sun |
Mon |
Tue |
Wed |
Thu |
Fri |
Sat |
");
- $currentDays = 1;
- for ($a =1; $a <=5; $a + +) {
- Print ("
");
$printDays | ");
| ");
$currentDays | ");
| ");
$currentDays | ");
$currentDays | ");
");
- Print ("
");
- }
- }
- ?>
Copy Code |