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 ''.$temp . ' | ';
35
$mday++;
36
} else {
37
echo ' | ';
38
}
39
}
40
echo '
';
41
}
42
43
echo '
44
';
45
}
46
?>
Author "Flowf's Blog"
http://www.bkjia.com/PHPjc/478650.htmlwww.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...