1,php日历代码一
复制代码 代码示例:
/**
* php日历
* by www.jbxue.com
*/
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, 0, 0, $date['mon'] + 1, 1, $date['year']) - 1);
$start = getdate(mktime(0, 0, 0, $date['mon'], 1, $date['year']));
$pre = date('Y-m-d', $start[0] - 1);
$next = date('Y-m-d', $end[0] + 86400);
$html = '
$html .= '
';$html .= '
$html .= '
';$html .= '
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 <<
< | $year - $month | > | >> | |||
日 | 一 | 二 | 三 | 四 | 五 | 六 |
VKN;
$nowtime = mktime(0,0,0,$month,1,$year);//当月1号转为秒
$daysofmonth = date(t,$nowtime);//当月天数
$weekofbeginday = date(w,$nowtime);//当月第一天是星期几
$weekofendday = date(w,mktime(0,0,0,$month+1,0,$year));//当月最后一天是星期几
$daysofprevmonth = date(t,mktime(0,0,0,$month,0,$year));//上个月天数
$count = 1;//计数
//列出上月后几天
for($i = 1 ; $i <= $weekofbeginday ; $i++)
{
echo "
".($daysofprevmonth-$weekofbeginday+$i)."";$count++;
}
//当月全部
for($i = 1 ; $i <= $daysofmonth ; $i++)
{
$css = ($count%7==0 || $count%7==1)?"weekday":"normalday";
if($i == $today) $css .= "today";
echo "
".$i."";if($count%7==0) echo "
";$count++;
}
//下月前几天
for ($i = 1;$i <= 6-$weekofendday;$i++)
{
echo "
".$i."";}
echo <<
VKN;
}
?>
calendar>>> 您可能感兴趣的文章:
php calender日历代码(解决2038问题)
php日历代码(附演示效果)
php日历代码分享 简单实用的php日历代码
php日历代码 php实现的高效日历代码
分享一例PHP简单日历代码
php简单日历的实现代码(可绑定事件)