<?php
//剥离日期
date_default_timezone_set("Asia/Harbin");
$riqi=getdate();
$nian=$riqi['year'];
$yue=$riqi['mon'];
$ri=$riqi['mday'];
$hour=$riqi['hours'];
$min=$riqi['minutes'];
$miao=$riqi['seconds'];
//表单判断
if(isset($_GET["yue"])){
$yue=intval($_GET["yue"]);
}
if(isset($_GET["nian"])){
$nian=intval($_GET["nian"]);
}
//一个月几天
$tianshu=date('t',mktime(0,0,0,$yue,1,$nian));
//月份第一天周几
$yuez=date('w',mktime(0,0,0,$yue,1,$nian));
$tian=0;
?>
<!-- 打印日历 -->
<table border="1" width="80%">
<tr>
<td width="60%">
<table border="1" width="100%">
<tr>
<th colspan="7">日历<?php echo $nian."年".$yue."月"?> 现在时间:<?php echo $hour.':'.$min.':'.$miao;?></th>
<tr>
<tbody bgcolor="#FF9900">
<tr>
<td>日</td>
<td>一</td>
<td>二</td>
<td>三</td>
<td>四</td>
<td>五</td>
<td>六</td>
</tr>
</tbody>
<tbody>
<?php for($h=1;$h<=6;$h++){?>
<tr>
<?php for($l=1;$l<=7;$l++){ ?>
<td bgcolor="<?php if($tian+1==$ri){echo "#FF6666";}?>" align="center">
<?php
if($h*$l<=$yuez && $h==1){
echo ' ';
}elseif($tian<$tianshu){
echo ++$tian;
}else{
echo ' ';
}
?>
</td>
<?php }?>
</tr>
<?php }?>
</tbody>
</table>
</td>
<!-- 年翻页 -->
<td>
<a href ="?nian=<?php echo $nian-1; ?>&yue=<?php echo $yue;?>">上一年</a>
<a href ="?nian=<?php echo $nian+1; ?>&yue=<?php echo $yue;?>">下一年</a>
<!-- 月翻页 -->
<!-- 左翻页 -->
<a href ="?yue=<?php if($yue-1<=0){echo '12';}else{echo $yue-1;} ?>&nian=<?php echo $nian; ?>">
<?php
if($yue-1<=0){
echo '<'.'12';
}else{
echo '<'.($yue-1);
}
?>月
</a>
<!-- 右翻页 -->
<a href ="?yue=<?php if($yue+1>12){echo '1';}else{echo $yue+1;} ?>&nian=<?php echo $nian; ?>">
<?php
if($yue+1>12){
echo '1';
}else{
echo $yue+1;
}?>月>
</a>
<!--表单提交-->
<form action="01.php" method="get">
<p>年: <input type="text" name="nian" /></p>
<p>月: <input type="text" name="yue" /></p>
<input type="submit" value="提交" />
</form>
</td>
</tr>
</table>
|