时间:2021-07-01 10:21:17 帮助过:18人阅读
01
02
03
"Content-Type" content="text/html; charset=utf8" />
04
05
#calendardiv,#calendar{width:252px;}
06
#cal_title{height:33px;line-height:33px;text-align:center;overflow:hidden;}
07
#cal_title strong{font-weight:bold;font-size:14px; }
08
#cal_title a{font-weight:bold;font-size:14px;text-decoration:none;}
09
#calendar{border-collapse:collapse;}
10
#calendar td{
11
text-align:center;
12
width:35px;
13
height:20px;
14
line-height:20px;
15
background-color:#efefef;
16
border-bottom:1px solid #fff;
17
border-right:1px solid #fff;
18
}
19
#calendar .even td{background-color:#e6e6e6;}
20
#calendar td .current{display:block;background-color:#f60;color:#fff;}
21
#calendar .current{background-color:#f60!important;color:#fff;}
22
#week td{color:#fff;background-color:#373737;}
23
24
25
26
27
$date = isset($_GET['d']) ? intval($_GET['d']) : '';
28
if($date)
29
{
30
$y = substr($date,0,4);
31
$m = substr($date,4,2);
32
$cur = mktime(0,0,0,$m,1,$y);
33
}
34
else
35
{
36
$cur = mktime();
37
}
38
39
list($year,$month,$day) = explode('-',date('Y-m-d',$cur));//年月日
40
$p = date('Ym',strtotime('last months',$cur));//前一月
41
$n = date('Ym',strtotime('next months',$cur));//后一月
42
$t = date('t',$cur); //当月多少天
43
$s = date('w',mktime(0,0,0,$month,1,$year)); //前补空白
44
$e = 6-(date('w',mktime(0,0,0,$month,$t,$year)));//后补空白
45
?>
46
"calendardiv">
47
"cal_title">"?d==$p?>" title="上一月">« =$year?>年=$month?>月 "?d==$n?>"title="下一月">»
48
"calendar">
49
"week">日 一 二 三 四 五 六
50
51
echo '';
52
for($i=0;$i<$s;$i++)
53
{
54
echo ' ';
55
}
56
for($d=1;$d<=$t;$d++)
57
{
58
$current=$d==$day?'class="current"':'';//当前样式
59
$r = ($d+$s)%7;//换行
60
61
echo "$d ";
62
if($r==0)
63
{
64
echo '';
65
echo '';
66
}
67
}
68
for($i=0;$i<$e;$i++)
69
{
70
echo ' ';
71
}
72
?>
73
http://www.bkjia.com/PHPjc/735155.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/735155.htmlTechArticle一个简单实现的日历,我不知道这段代码实现的方法有没有问题,没有参考前辈,等你理解我的烂代码之后,再欣赏一下别人的优秀代码,...