-
- //calendar.php
-
- /*******************************
- * 判斷是否閏年的函數*
- * 可以根據更複雜的演算法改進*
- *******************************/
- function Leap_year($year) *****************************
- * 對一些變數賦值運算*
- * 特別注意對二月的賦值*
- *******************************/
- function Leap_year($year) *****************************
- * 顯示表格中的一格*
- * 顯示的內容和顏色可變*
- ****************************** {
- {
- if($year% 4 == 0) // 基本規則
- {
- return true ; // 是閏年
- }
- else
- {
- return false;
- > }
- }
-
- /***/
- function setup()
- {
- global $mon_num;
- $mon_num=array(31,30, 31,30,31,30,31,31,30,31,30,31);
- 全域$mon_name;
- $mon_name=array("一","二","三","四",
- "五","六","七","八",
- "九", “十”、“十一”、“十二”);
- if (leap_year( $firstday[year])) // 基本規則
- {
- $mon_num[1]=29; // 是閏年
- }
- else
- {
- $mon_num[1] $mon_num[1] =28;
- }
- }
-
- /***/
- function showline($content,$show_color)
- {
- $begin_mark = "
"; - $begin_mark =$begin_mark."";
- $end_mark = "
| ";
- echo $ begin_mark.$content.$end_mark ; }
- ?>
-
-
-
-
社群日曆
-
-
-
-
- //取得目前的日期
- $firstday = getdate(mktime(0,0,0,date("m"),1,date("Y")));
-
- setup();
- //顯示表格的名稱
- echo "";
- echo "
"; - echo "
"; - echo "";
- echo "$firstday[year]年 ".$mon_name[$firstday[mon]-1]."月 月曆";
- echo "
";
- echo "
| ";
-
- //表頭
- $weekDay[0] = "日";
- $weekDay[1] = "一";
- $weekDay [2] = "二";
- $weekDay[3] = "三";
- $weekDay[4] = "四";
- $weekDay[5] = "五";
- $weekDay[6] = "六";
-
- echo "
"; -
- //顯示表格的第一行
- for ($dayNum = 0; $dayNum showline($weekDay[$dayNum],"red");
- }
-
- echocho "
";
- $toweek=$firstday[wday];//本月的第一天是星期幾
- $lastday=$mon_num[$firstday[mon]-1];//本月的最後一天是星期幾
- $day_count = 1;//目前應該顯示的天數
- $up_to_firstday = 1;//是否顯示到本月的第一天
-
- for ( $row = 0; $row { echo "
"; - for ($col=1; $col {
- //在第一天前面顯示的都是"空"
- if (($up_to_firstday $lastday))
- {
- echo "
 D>"; - $up_to_firstday++;
- }
- else
- {
- //顯示本月中的某一天
- showline($day_count,"blue");
- $day_count++;
- }
- }
- echo "
|
";
- }
-
- echo "
";
- echo "
";
- ?>
-
-
複製程式碼
>>> 您可能有興趣的文章:
php calender日曆程式碼(解決2038問題)
php日曆程式碼(附示範效果)
php日曆程式碼分享 簡單實用的php日曆程式碼
php日曆程式碼 php實作的高效日曆程式碼
php日曆程式碼 三個不錯的php日曆程式碼
php簡單日曆的實作碼(可綁定事件)
|