20191107万年历
<?php $today=time(); //获取传过来的‘年’ 不然获取当年的‘年’ $year=isset($_GET['year'])?$_GET['year']:date("Y",$today); //获取传过来的‘月’ 不然获取当年的‘月’ $month=isset($_GET['month'])?$_GET['month']:date("m",$today); //限制月份范围 $month=$month>12?12:$month; $month=$month<1?1:$month; //年月的加减并回传 echo "<a href='?year=".($year-1)."&month=".$month."'><<</a> ". $year."年 <a href='?year=".($year+1)."&month=".$month."'>>></a><br />"; echo "<a href='?year=".$year."&month=".($month-1)."'><<</a> ".$month."月 <a href='?year=".$year."&month=".($month+1)."'>>></a>"; $firstday=strtotime($year."-".$month."-1"); //获取天数 $n=date("t",$firstday); //获取星期几 $wd=date("w",$firstday); ?> <!--打印表格--> <table cellspacing=0 border=1 cellpadding=0 width=500> <tr align=center> <th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th> </tr><tr align=center> <?php $cnt=1; $darr=getdate($today); // print_r($darr); for($i=1-$wd;$i<=$n;$i++){ //如果当前年月日等于当前时间 改变样式为‘红色’ if($darr['year']==$year && $darr['mon']==$month && $darr['mday']==$i){ echo "<td><font color=red>".($i<=0?"":$i)."</font></td>"; }else{ echo "<td>".($i<=0?"":$i)."</td>"; } if($cnt%7==0)echo "</tr><tr align=center>"; $cnt++; } ?> </table>
万年历