php日历35,php日历代码三个不错的php日历代码

/**

* php日历代码

* edit: bbs.it-home.org

*/

function calendar()

{

if($_GET['ym'])

{

$year = substr($_GET['ym'],0,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 <<<<

<

$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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值