电脑安全

您当前的位置:主页 > 电脑安全 >

php日历代码-网络编程

来源:[db:来源]标题:   日历    编辑:电脑技术全能网 时间:2019-09-22 18:28

原标题:php日历代码-网络编程
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>php日历代码</title><style 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><body><div id="calendarTitle"><div class="titleSpan">日</div><div class="titleSpan">一</div><div class="titleSpan">二</div><div class="titleSpan">三</div><div class="titleSpan">四</div><div class="titleSpan">五</div><div class="titleSpan">六</div><div 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="daySpan">X</div>');}else{echo('<div class="daySpan">'.$i.'</div>'); }} ?></div><div class="clear"></div></body></html>

上一篇:php php 删除mysql 记录教程-网络编程

下一篇:没有了