This article describes the PHP simple calendar implementation method. Share to everyone for your reference, specific as follows:
The screenshot of the running effect is as follows:
The specific code is as follows:
<?php/* Created on 2016-7-20/Simcalendar (' 2016-08 ');//display August calendar function Simcalendar ($date) {/** * simple calendar output, This function requires cal_days_in_month support * @param $date y-m The date to be exported * * echo ' <table border= ' 1 ' > <thead> <TR&G
T <th> Day </th> <th> one </th> <th> two </th> <th> three </th> <th > Four </th> <th> five </th> <th> six </th> </tr> </thead> <tbody>
;';
$date _array = Explode ('-', $date); $start _week = 0;//starting from Sunday for 0 $month = Cal_days_in_month (Cal_gregorian, $date _array[1], $date _array[0]);//days of the month $wsta R = Date (' W ', Strtotime ($date. '-01 '); $rows = Ceil (($wstar + $month)/7), or the total number of rows $mday = 1;//days for ($i = 0; $i < $rows; $i + +)
{echo ' <tr> ';
for ($d = 0; $d < 7; $d + +) {$nowday = 7 * $i + $d + $start _week;
if ($nowday >= $wstar && $mday <= $month) { $temp = Date (' d ', Strtotime ($date. '-' .
$mday)); Echo ' <td> '. $temp.
' </td> ';
$mday + +;
else {echo ' <td> </td> ';
} echo ' </tr> ';
Echo ' </tbody> </table> ';
}?>
For more information about PHP interested readers can view the site topics: "PHP date and Time usage summary", "PHP object-oriented Program Design Primer", "PHP Mathematical Operation Skills Summary", "PHP Array" Operation Techniques Encyclopedia, "PHP Data structure and algorithm tutorial", " Summary of PHP programming algorithm and the summary of common PHP database operation skills
I hope this article will help you with the PHP program design.