ホームページ  >  記事  >  バックエンド開発  >  PHP が月間カレンダー コードを自動生成する_PHP チュートリアル

PHP が月間カレンダー コードを自動生成する_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-21 16:09:16709ブラウズ

/*
Function Written by Nelson Neoh @3/2004.
For those who wants to utilize this code, please do not remove this remark.
If you have done any enhancement to this code, please post the copy at http://www.dev-club.com PHP board. Thank you.

関数の使用法: カレンダー(月,年)
*/

関数カレンダー($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));
$pre Year = strftime("%Y ",mktime (0,0,0,$MM-1,1,$YYYY));
$nextMonth = strftime("%m",mktime (0,0,0,$MM+1,1,$YYYY) ));
$next Year = strftime("%Y",mktime (0,0,0,$MM+1,1,$YYYY));
print("

");
print("");
print("");
print("");
print("");
print("金<");

$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("");
}
for($z=1;$z print("");
}
for($y=$firstDay;$y print("< td>$currentDays");
$currentDays++;
}
} elseif($firstDay!=0 && $currentDays==1){
for($z=1;$z print("");
}
for($y=$firstDay;$y<7;$y++){
print("");
$currentDays++;
}
} else {
for($u =1;$u<=7 && $currentDays<=$days;$u++){
print("");
$currentDays++;
}
}
print("< ;/tr>");
}
print("
P".strftime("%b %Y",mktime (0,0,0,$MM,1,$YYYY))."N
SunMon水< /th>
$printDays  $currentDays$currentDays
");
}
}
?>

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/314607.html技術記事 ?php /* 関数は Nelson Neoh @3/2004 によって作成されました。このコードを利用したい方は、このコメントを削除しないでください。このコードに何らかの機能拡張を行った場合は、...
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。