PHP Calendar_PHP Tutorial

WBOY
Release: 2016-07-13 17:45:42
Original
1012 people have browsed it

02
SimCalendar('2011-08');
03
function SimCalendar($date)
04
{
05
/**
06
* Simple calendar output, this function requires the support of cal_days_in_month
07
* @param $date Y-m The date to be output
08
​​*/
09
echo '


10

11
                                                                                        12
                                                                                                                        13
                                                                                                                            14
                                                                                                                                                      15
                                                                                                                                             16
                                                                                                                                                                            17
                                                                                                                        18
                                                                                                                        19
                                                                                        20

21
';
22
          $date_array = explode('-', $date);
23
           $start_week = 0;//Start from Sunday to 0
24
         $month = cal_days_in_month(CAL_GREGORIAN, $date_array[1], $date_array[0]);//The number of days in the month
25
           $wstar = date('w', strtotime($date . '-01'));//The day of the week that the current month starts
26
           $rows = ceil(($wstar + $month) / 7);//Total number of rows
27
         $mday = 1;//The day
28
for ($i = 0; $i < $rows; $i++) {
29
echo '';
30
for ($d = 0; $d < 7; $d++) {
31
                    $nowday = 7 * $i + $d + $start_week;
32
If ($nowday >= $wstar && $mday <= $month) {
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
?>
Author "Flowf's Blog"

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478650.htmlTechArticle?php 02 SimCalendar(2011-08); 03 function SimCalendar($date) 04 { 05 /** 06 * Simple calendar output, this function requires cal_days_in_month support 07 * @param $date Y-m The date to be output...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!