php日历代码

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN xmlns=
content=text/html; charset=utf-8 /titlephp日历代码/titlestyle
type=text/css!–#calendarTitle{ width:210px;}#澳门新葡亰手机版,calendarMain{
width:210px;}.clear{ clear:both;}.titleSpan{ width:30px;
text-align:center; float:left;}.daySpan{ width:30px; text-align:center;
float:left;}–/style/head

bodydiv id=calendarTitlediv class=titleSpan日/divdiv
class=titleSpan一/divdiv class=titleSpan二/divdiv
class=titleSpan三/divdiv class=titleSpan四/divdiv
class=titleSpan五/divdiv class=titleSpan六/divdiv class=clear/div/div

div id=calendarMain

?@date_default_timezone_set(‘+8’);

function week2day($str) {$days = array(‘Mon’, ‘Tue’, ‘Wed’, ‘Thu’,
‘Fri’, ‘Sat’, ‘Sun’);return array_search($str, $days) + 1;}

$selectTimestamp = time();$curMonth = date(‘n’,
$selectTimestamp);$curYear = date(‘Y’, $selectTimestamp);$curDay =
week2day(date(‘D’, $selectTimestamp));$todayNum = date(‘j’,
$selectTimestamp);$curMonthTotal = date(‘t’, $selectTimestamp);$firstDay
= week2day(date(‘D’, mktime(0,0,0,$curMonth,1,$curYear)));$lastDay =
week2day(date(‘D’, mktime(0,0,0,$curMonth,$curMonthTotal,$curYear)));

for($i=0;$i$firstDay;$i++){echo(‘div class=daySpan /div’);}

for($i=1;$i=$curMonthTotal;$i++){if($i == $todayNum){echo(‘div
class=daySpanX/div’);}else{echo(‘div class=daySpan’.$i.’/div’); }

} ?/div

div class=clear/div/body/html