PHP   发布时间:2019-11-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php日历[测试通过]大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

比较不错的一款php日历代码
<div class="codetitle"><a style="cursOR: pointer" data="93403" class="copybut" id="copybut93403" onclick="doCopy('code93403')"> 代码如下:

<div class="codebody" id="code93403">
<?php
/
日历

Copyright(C) 2007 by 陈毅鑫(深空). All rights reserved
To contact the author write to {@link mailto:shenkong@php.net}
@author 陈毅鑫(深空)
/
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
}
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
$date = getdate(strtotime($datE));
$end = getdate(mktime(0,$date['mon'] + 1,1,$date['year']) - 1);
$start = getdate(mktime(0,$date['mon'],$date['year']));
$pre = date('Y-m-d',$start[0] - 1);
$next = date('Y-m-d',$end[0] + 86400);
$html = '<table border="1">';
$html .= '<tr>';
$html .= '<td><a href="' . $php_SELF . '?date=' . $pre . '">-</td>';
$html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
$html .= '<td><a href="' . $php_SELF . '?date=' . $next . '">+</td>';
$html .= '</tr>';
$arr_tpl = array(0 => '',1 => '',2 => '',3 => '',4 => '',5 => '',6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $i < $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_tpl;
}
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
$j++;
}
}
foreach ($date_arr as $value) {
$html .= '<tr>';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '<td>' . $v . '</td>';
} else {
$html .= '<td>' . $v . '</td>';
}
} else {
$html .= '<td></td>';
}
}
$html .= '</tr>';
}
$html .= '</table>';
echo $html;
?>

php日历代码2
<div class="codetitle"><a style="cursOR: pointer" data="85117" class="copybut" id="copybut85117" onclick="doCopy('code85117')"> 代码如下:
<div class="codebody" id="code85117">
<?php
/

日历
/
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
}
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
$date = getdate(strtotime($datE));
$end = getdate(mktime(0,$end[0] + 86400);
$html = '<table width="200" border="1" cellspacing="0" bordercolor="#999999"
align="center" style="line-height:150%; font-family:Verdana,宋体; font-size: 12px;">';
$html .= '<tr>';
$html .= '<td><a href="' . $php_SELF . '?date=' . $pre . '">-</td>';
$html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
$html .= '<td><a href="' . $php_SELF . '?date=' . $next . '">+</td>';
$html .= '</tr>';
$arr_tpl = array(0 => '',6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $i < $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_tpl;
}
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
$j++;
}
}
foreach ($date_arr as $value) {
$html .= '<tr>';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '<td>' . $v . '</td>';
} else {
$html .= '<td>' . $v . '</td>';
}
} else {
$html .= '<td> </td>';
}
}
$html .= '</tr>';
}
$html .= '</table>';
echo $html;
?>

下面这个也不错,提示有错误,思路清晰
<div class="codetitle"><a style="cursOR: pointer" data="63091" class="copybut" id="copybut63091" onclick="doCopy('code63091')"> 代码如下:
<div class="codebody" id="code63091">
<?php
functioncalendar()
{
if($_GET['ym'])
{
$year=substr($_GET['ym'],4);
$month=substr($_GET['ym'],4,(strlen($_GET['ym'])-4)); if($month>12)
{
$year+=floor($month/12);
$month=$month%12;
}
if($year>2030)$year=2030;
if($year<1980)$year=1980;
} $year=isset($year)?$year:date('Y');
$month=isset($month)?$month:date('n'); if($year==date('Y')&&$month==date('n'))$today=date('j'); if($month-1==0)
$prevmonth=($year-1)."12";
else$prevmonth=$year.($month-1); if($month+1==13)
$nextmonth=($year+1)."1";
else$nextmonth=$year.($month+1); $prevyear=($year-1).$month;
$nextyear=($year+1).$month; echo<<<VKN
<tablewidth="200"border="0"celLPADding="2"cellspacing="2">
<tr>
<tdclass="weekday"><ahref="?ym=$prevyear"><<</td>
<tdclass="normalday"><ahref="?ym=$prevmonth"><</td>
<tdcolspan="3"class="normalday">$year-$month</td>
<tdclass="normalday"><ahref="?ym=$nextmonth">></td>
<tdclass="weekday"><ahref="?ym=$nextyear">>></td>
</tr>
<tr>
<tdwidth="27"class="weekday">日</td>
<tdwidth="27"class="normalday">一</td>
<tdwidth="27"class="normalday">二</td>
<tdwidth="27"class="normalday">三</td>
<tdwidth="27"class="normalday">四</td>
<tdwidth="27"class="normalday">五</td>
<tdwidth="27"class="weekday">六</td>
</tr>
VKN;
$nowtime=mktime(0,$month,$year);//当月1号转为秒
$daysofmonth=date(t,$nowtimE);//当月天数
$weekofbeginday=date(w,$nowtimE);//当月第一天是星期几
$weekofendday=date(w,mktime(0,$month+1,$year));//当月最后一天是星期几
$daysofprevmonth=date(t,$year));//上个月天数 $count=1;//计数
//列出上月后几天
for($i=1;$i<=$weekofbeginday;$i++)
{
echo"<tdclass='othermonth'>".($daysofprevmonth-$weekofbeginday+$i)."</td>";
$count++;
}
//当月全部
for($i=1;$i<=$daysofmonth;$i++)
{
$css=($count%7==0||$count%7==1)?"weekday":"normalday";
if($i==$today)$css.="today"; echo"<tdclass='".$css."'>".$i."</td>";
if($count%7==0)echo"</tr><tr>";
$count++;
}
//下月前几天
for($i=1;$i<=6-$weekofendday;$i++)
{
echo"<tdclass='othermonth'>".$i."</td>";
} echo<<<VKN
<tr>
<tdcolspan="7"></td>
</tr>
</table>
VKN;
}
?>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<htmlxmlns="http://www.w3.org/1999/xhtml"&gt;

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
calendar
<styletype="text/css">



<?phpcalendar();?>


大佬总结

以上是大佬教程为你收集整理的php日历[测试通过]全部内容,希望文章能够帮你解决php日历[测试通过]所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:php日历
猜你在找的PHP相关文章
其他相关热搜词更多
phpJavaPython程序员load如何string使用参数jquery开发安装listlinuxiosandroid工具javascriptcap