日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php日历表代码,PHP输出日历表代码实例

發布時間:2024/8/1 php 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php日历表代码,PHP输出日历表代码实例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
月歷表

$month = array("元月","一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");

$enmonth = array("元月","january" ,"february" ,"marcy" ,"april" ,"may" ,"june" ,"july" ,"august" ,"september" ,"october" ,"november" ,"december");

$week = array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

$backcolor = array("#ffc" , "#fff" , "#9f6" , "#ffc" , "#6f0" , "#6f6" , "#f90" , "#f06" , "#f00" , "#fc3" , "#ff6" , "#f99");

function printmon($year, $mon)

{

date_default_timezone_set("asia/shanghai");

global $month;

global $enmonth;

global $week;

global $backcolor;

$startdate =strtotime("1 $enmonth[$mon] $year"); //獲取查詢的年月

$enddate = strtotime("+1 month",$startdate); //獲取下一個月的開始日期作為月歷輸出的截止時間

$thedate = getdate($startdate); //把日期轉化為字符串格式

$color = $backcolor[$mon]; //設置月歷的背景顏色

echo("

$ym = $year . "年". $month[$mon];

echo("

$ym

");

echo("

");

for ($i=0; $i<7; $i++) //輸出星期幾

{

echo("

");

echo("

$week[$i]

");

echo("

");

}

echo("

");

$theweek = $thedate[wday];//判斷當天是星期幾

for ($i=0; $i<6; $i++)

{

echo("

");

for ($j=0; $j<7; $j++)

{

echo("

");

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;

}

}

echo("

}

?>

請輸入要查看的年號和月份(查詢范圍為1970年1月1日至2038年)

年月

$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日历表代码,PHP输出日历表代码实例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。