简易万年历php代码

万年历.png

下面是源码,很简单:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

<style type=text/css>

A:link{

color:#FFFFFF;

font-size:13px;

}

A:visited{

color:#FFFFFF;

text-decoration:none;

}

A:hover{

text-decoration:underline;

}

TD{

text-align:center;

font-size:12px;

background-color:#E6E6E6;

border:   #FFFFFF solid 1px;

color:#198281;

height:20px;

}

TD.title{

background-color:#9a9a9a;

color:#FFFFFF;

font-weight:bold;

}

TABLE{

border-collapse:collapse;

border-color:white;

border:   #198281 solid 1px;

}

</style>

<?php

date_default_timezone_set("Asia/Shanghai");

$today = time();

$year =@ $_GET["year"];

$month = @$_GET["month"];

if($year==''$year date("Y",$today);

if($month==''$month date("m",$today);

if((int)$month==0){$year-=1;$month=12;}

$time mktime(0,0,0,$month,1,$year);

$year date('Y',$time);

$month date('m',$time);

echo "<table width=260 cellspacing=0 cellpadding=0>";

echo "<tr><td colspan=7 class=title>";

$str   "<a href=?year=".($year-1)."&month=".$month.">";

$str .= "&laquo;</a> ".$year."年 ";

$str .= "<a href=?year=".($year+1)."&month=".$month.">";

$str .= "&raquo;</a>   ";

$str .= "<a href=?year=".$year."&month=".($month-1).">";

$str .= "&laquo;</a> ".$month."月 ";

$str .= "<a href=?year=".$year."&month=".($month+1).">";

$str .= "&raquo; </a>";

echo $str;

echo "</td></tr>";

echo     "<tr>";

$str   "<td>一</td>";

$str .= "<td>二</td>";

$str .= "<td>三</td>";

$str .= "<td>四</td>";

$str .= "<td>五</td>";

$str .= "<td>六</td>";

$str .= "<td>七</td>";

echo $str;

echo "</td>";

//这个月有多少天

$days date('t',$time);

//第一天是星期几

$fstdw date('N',$time);

//要输出多少行

$rows ceil(($days $fstdw-1)/7);

$cd = 1;

for($i=0;$i<$rows;$i++){

echo "<tr>";

    for($j=0;$j<7;$j++){

     echo "<td>";

     if($cd >= $fstdw && $cd<$days+$fstdw){

        $oday $cd-$fstdw+1;

        if($oday==date('d',time()))

echo "<b><u>";

          echo ($cd-$fstdw+1);

     }else{

        echo " ";

     }

     $cd++;

     echo "</td>";

    }

echo "</tr>";

}

echo "</table>";

?>

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雨信

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值