用 php 编写的日历


网上有很多JavaScript编写的日历,这种日历读取的是本地的时间,可能会不准确。所以想找一个用php编写的,能读取服务器时间的日历,但是一直都找不到合适的,于是我自己尝试着写了一个。 代码拷贝框
<?php $mnow=(isset($HTTP_GET_VARS['month']) && intval($HTTP_GET_VARS['month'])>0 && intval($HTTP_GET_VARS['month'])<13)?intval($HTTP_GET_VARS['month']):date("m"); $ynow=(isset($HTTP_GET_VARS['year']) && intval($HTTP_GET_VARS['year'])>1969 && intval($HTTP_GET_VARS['year'])<2038)?intval($HTTP_GET_VARS['year']):date("Y"); $mtime=mktime(0,0,0,$mnow,date("d"),$ynow); $f=date("w",mktime(0,0,0,$mnow,1,$ynow))-1; echo "<table id=https://www.jb51.net/article/\"calendar\" border=https://www.jb51.net/article/\"0\" cellpadding=https://www.jb51.net/article/\"2\" cellspacing=https://www.jb51.net/article/\"1\">"; echo "<tr><td colspan=https://www.jb51.net/article/\"4\" align=https://www.jb51.net/article/\"center\" class=https://www.jb51.net/article/\"calendartitle\"><a href=https://www.jb51.net/article/\"?".($mnow!=date("m")?"month=".intval($mnow)."&":"")."year=".(intval($ynow)==1970?"1970":intval($ynow)-1)."https://www.jb51.net/article/\">&lt;</a>".$ynow."<a href=https://www.jb51.net/article/\"?".($mnow!=date("m")?"month=".intval($mnow)."&":"")."year=".(intval($ynow)==2037?"2037":intval($ynow)+1)."https://www.jb51.net/article/\">&gt;</a></td><td colspan=https://www.jb51.net/article/\"3\" align=https://www.jb51.net/article/\"center\" class=https://www.jb51.net/article/\"calendartitle\"><a href=https://www.jb51.net/article/\"?month=".(intval($mnow)==1?"12":intval($mnow)-1).($ynow!=date("Y")?"&year=".intval($ynow):"")."https://www.jb51.net/article/\">&lt;</a>".date("M",$mtime)."<a href=https://www.jb51.net/article/\"?month=".(intval($mnow)==12?"1":intval($mnow)+1).($ynow!=date("Y")?"&year=".intval($ynow):"")."https://www.jb51.net/article/\">&gt;</a></td></tr>"; echo "<tr><td class=https://www.jb51.net/article/\"calendartop\">S</td><td class=https://www.jb51.net/article/\"calendartop\">M</td><td class=https://www.jb51.net/article/\"calendartop\">T</td><td class=https://www.jb51.net/article/\"calendartop\">W</td><td class=https://www.jb51.net/article/\"calendartop\">T</td><td class=https://www.jb51.net/article/\"calendartop\">F</td><td class=https://www.jb51.net/article/\"calendartop\">S</td></tr>"; for($i=0;$i<date("t",$mtime)+$f+1;$i++){ if($i%7==0)echo "<tr>"; echo "<td".(($i-$f==intval(date("d")) && $mnow==date("m") && $ynow==date("Y"))?" id=https://www.jb51.net/article/\"calendartoday\"":"").(($i%7==0
$i%7==6)?" class=https://www.jb51.net/article/\"calendarw\"":"").">"; if($i>$f)echo $i-$f; echo "</td>"; if($i%7==6)echo "</tr>"; } if($i%7<6 && $i%7>0)echo "<td colspan=https://www.jb51.net/article/\"".(7-$i%7)."https://www.jb51.net/article/\"></td></tr>"; if($i%7==6)echo "<td></td></tr>"; echo "</table>"; ?>
[Ctrl+A 全部选择 然后拷贝]

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/eefcee04a0aba630d3d7030f8f240df6.html