PHP学習ノート月間カレンダー

WBOY
リリース: 2016-06-23 13:40:41
オリジナル
1793 人が閲覧しました


< html xmlns="http://www.w3.org/1999/xhtml">


月間カレンダー
$MONTH = array("1月","1月","2月","3月","4月","5月", "6 月","7 月","8 月","9 月","10 月","11 月","12 月");
$enMONTH = array ("1 月" ,"2 月" ,"マーシー" ,"4 月"); ,"5月" ,"6月" ,"7月" ,"8月" ,"9月" ,"10月" ,"11月" ,"12月")
$WEEK = array("日曜日","月曜日","火曜日); ","水曜日","木曜日","金曜日","土曜日");
$BACKCOLOR = array("#FFC " , "#FFF" , "#9F6" , "#FFC" , "#6F0" , "#6F6" 、 "#F90" 、 "#F06" 、 "#F00" 、 "#FC3" 、 "#FF6 " 、 "#F99");

関数 PrintMon($year, $mon)
{
date_default_timezone_set("アジア/上海");
グローバル $MONTH;
グローバル $BACKCOLOR

$startdate ("1 $enMONTH" $year"); /クエリの年と月を取得します
$enddate = strtotime("+1 month",$startdate); //次の月を取得します 開始日は月次カレンダー出力の期限として使用されます
$theDate = getdate($ startdate); //日付を文字列形式に変換します
$color = $BACKCOLOR[$mon] //月間カレンダーの背景色を設定します

echo( "

");
$ym = $year . "year". $MONTH[$mon];
echo ("");
echo("");
for ($i=0; $i {
echo( "");
}
echo("");


$theWeek = $theDate[wday];// 曜日を判断します ( $i=0; $i {
echo("");
for ($j=0; $j<7; $j++)
{
echo("< td width="90", height="40" align="center" >");
if ($startdate < $enddate && $theWeek == $j)//日付を出力します の列に移動します対応する曜日、および今月の日付を超えないように注意してください
{
$theDay = $theDate[mday];
echo("

$theDay

");
$startdate = strtotime( "+1 day", $startdate); //日付を 1 日進めます
$theDate = getdate($startdate);// 日付を更新します
$theWeek = ($theWeek + 1) % 7;/ /週を更新します
}
echo("");
}
echo("")
if ($startdate == $enddate) //すべての日付が出力された場合、ループを終了します
{
$ i = 6; }
}






範囲は 1970 年 1 月 1 日から 2038 年です)



< input type="submit">


$year = $_POST['myyear'];  $month = $_POST['myMonth'];
if (is_numeric($year) && $year >= 1970 && $year <2038)
{
if (is_numeric($month) && $month >= 1 && $month <=12)
{
PrintMon($year, $month);
}
else if($month != NULL)
{
echo("月份不对" . "
");
}
}
else if($year != NULL)
{
echo("年份不对" . "
");
}
?>



関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!

$ym

");
echo("

$WEEK[$i]

"); "