Heim  >  Artikel  >  Backend-Entwicklung  >  PHP日历_PHP教程

PHP日历_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:45:421014Durchsuche

02
SimCalendar('2011-08');
03
function SimCalendar($date)
04
{
05
    /**
06
     * 简单日历输出,本函数需要cal_days_in_month的支持
07
     * @param $date Y-m 要输出的日期
08
     */
09
    echo '


10
   
11
       
12
           
13
           
14
           
15
           
16
           
17
           
18
           
19
       
20
   
21
    ';
22
        $date_array = explode('-', $date);
23
        $start_week = 0;//从星期天开始为0
24
        $month = cal_days_in_month(CAL_GREGORIAN, $date_array[1], $date_array[0]);//当月的天数
25
        $wstar = date('w', strtotime($date . '-01'));//当月从星期几天始
26
        $rows = ceil(($wstar + $month) / 7);//总行数
27
        $mday = 1;//第几天
28
        for ($i = 0; $i 29
            echo '';
30
            for ($d = 0; $d 31
                $nowday = 7 * $i + $d + $start_week;
32
                if ($nowday >= $wstar && $mday 33
                    $temp = date('d', strtotime($date . '-' . $mday));
34
                    echo '';
35
                    $mday++;
36
                } else {
37
                    echo '';
38
                }
39
            }
40
            echo '';
41
        }
42
    
43
    echo '
44
'.$temp . ' 
';
45
}
46
?>
作者“Flowf的博客”

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478650.htmlTechArticle?php 02 SimCalendar(2011-08); 03 function SimCalendar($date) 04 { 05 /** 06 * 简单日历输出,本函数需要cal_days_in_month的支持 07 * @param $date Y-m 要输出的日期...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn