table #week {
text-align:center;
background-color:#cccccc;
}
.weekday {color:red}
table tr {
text-align:center;
background-color:#ffffcc;
}
#caption {
font:bold 20px 幼圆,宋体;
}
#query {
width:500px;
height:10px;
margin:50px auto;
text-align:center;
}
//如果您提交了时间则显示您提交年月的日历,否则显示当前月份日历
if ($_GET['month'] && $_GET['year'])
{
$month = $_GET['month'];
$year = $_GET['year'];
}
else
{
$month = date ('m');
$year = date ('Y');
}
$weekid = date ('w',mktime(0,0,0,$month,1,$year));//某年某月第一天是星期几。0-7分别代表星期日-星期六
$countdays = date('t',mktime(0,0,0,$month,1,$year));//某年某个月的天数
$arr_days = array ();//数组$arr_days代表某个月的每一天
//初始化数组$arr_days
for ($i = 0; $i <= 41; $i++)
{
$arr_days[$i] = " ";
}
//给$arr_days数组赋值
for ($i = $weekid, $j = 1; $j <= $countdays; $i++, $j++)
{
$arr_days[$i] = $j;
}
?>
年
月
Sun | Mon | Tue | Wed | Thu | Fir | Sat |
//表格输出
for ($i = 0; $i <= 41; $i++)
{
if ($i % 7 == 0)
{
echo '
';}
echo '
'.$arr_days[$i].'';if (($i + 1) % 7 == 0)
{
echo '
';}
}
?>