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>

时间: 2024-11-01 04:19:50

php日历代码的相关文章

php Calender(日历)代码

 这篇文章主要介绍了php Calender(日历)代码,有需要的朋友可以参考一下 代码如下:    代码如下: <?php /**  *   * 我的日历  * date_default_timezone_set date mktime  * @param int $year  * @param int $month  * @param string $timezone  * @author fc_lamp  */ function myCalender($year = '', $month

黑色风格的JS日历代码,左右箭头翻页年、月

  黑色风格的JS日历代码,通过左右箭头可翻页至某年.某月,从外观上来说与灰色的背景搭配得完美,国外网站搞的,界面语言是英文的,如果您打算用可以自己修改为中文哦,别告诉我你连12月和7个星期的英语单词也不会哦! 示例: <title>经典的JS日历</title> <STYLE> body { background-color:#202020;} td { font-family:Tahoma;font-size:11px;} .calendarTable { back

javascript html实现网页版日历代码_javascript技巧

本文实例为大家分享了网页版日历代码,供大家参考,具体内容如下 效果图: 实现代码: <html> <head> <link rel="stylesheet" type="text/css" href="Skin.css"> <style> <!-- table{ text-align: center } --> </style> </head> <body&

ASP实现的日历代码实例程序

程序|日历 <style> td { font-family: "宋体"; font-size:9pt} </style> <body bgcolor="eeeeee"> <table width="180" cellpadding="0" cellspacing="1" bgcolor="dddddd" align=center> <

简单的个人博客日历代码,时钟演示

<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="keywords" content="Html日历插件,Html精美日历插件,Jquery多功能日历插件" /> <meta name="description" content="Html日历插件,多功能-彭亚欧个人博客代

php Calender(日历)代码分享_php实例

代码如下: 复制代码 代码如下: <?php/** *  * 我的日历 * date_default_timezone_set date mktime * @param int $year * @param int $month * @param string $timezone * @author fc_lamp */function myCalender($year = '', $month = '', $timezone = 'Asia/Shanghai'){     date_defau

简单 js 日历代码

 代码如下 复制代码 <style type="text/css"> *{ margin:0; padding:0; font:10px tahoma; } #calender{ text-align:center; width:147px; font-size:10px; /*color: #27B0C1;*/ margin:12px 0 12px 6px; border-top:1px solid #EEEEEE; border-left:1px solid #EEEE

日历代码

日历 <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="Fron

PHP实现的简单日历代码

日历 //calendar.php <?                                                                           /*******************************                                             *   用来判断是否闰年的函数    *                                             *   可以根据更复杂的算