一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php日歷[測(cè)試通過]

比較不錯(cuò)的一款php日歷代碼
復(fù)制代碼 代碼如下:
<?php
/**
* 日歷
*
* Copyright(c) 2007 by 陳毅鑫(深空). All rights reserved
* To contact the author write to {@link mailto:shenkong@php.NET}
* @author 陳毅鑫(深空)
*/
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
}
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
$date = getdate(strtotime($date));
$end = getdate(mktime(0, 0, 0, $date['mon'] + 1, 1, $date['year']) - 1);
$start = getdate(mktime(0, 0, 0, $date['mon'], 1, $date['year']));
$pre = date('Y-m-d', $start[0] - 1);
$next = date('Y-m-d', $end[0] + 86400);
$html = '<table border="1">';
$html .= '<tr>';
$html .= '<td><a href="' . $php_SELF . '?date=' . $pre . '">-</a></td>';
$html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
$html .= '<td><a href="' . $php_SELF . '?date=' . $next . '">+</a></td>';
$html .= '</tr>';
$arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $i < $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_tpl;
}
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
$j++;
}
}
foreach ($date_arr as $value) {
$html .= '<tr>';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '<td><b>' . $v . '</b></td>';
} else {
$html .= '<td>' . $v . '</td>';
}
} else {
$html .= '<td> </td>';
}
}
$html .= '</tr>';
}
$html .= '</table>';
echo $html;
?>

php日歷代碼2
復(fù)制代碼 代碼如下:
<?php
/**
* 日歷
*/
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Chongqing');
}
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
$date = getdate(strtotime($date));
$end = getdate(mktime(0, 0, 0, $date['mon'] + 1, 1, $date['year']) - 1);
$start = getdate(mktime(0, 0, 0, $date['mon'], 1, $date['year']));
$pre = date('Y-m-d', $start[0] - 1);
$next = date('Y-m-d', $end[0] + 86400);
$html = '<table width="200" border="1" cellspacing="0" bordercolor="#999999"
align="center" style="line-height:150%; font-family:Verdana,宋體; font-size: 12px;">';
$html .= '<tr>';
$html .= '<td><a href="' . $php_SELF . '?date=' . $pre . '">-</a></td>';
$html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
$html .= '<td><a href="' . $php_SELF . '?date=' . $next . '">+</a></td>';
$html .= '</tr>';
$arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$date_arr = array();
$j = 0;
for ($i = 0; $i < $end['mday']; $i++) {
if (!isset($date_arr[$j])) {
$date_arr[$j] = $arr_tpl;
}
$date_arr[$j][($i+$start['wday'])%7] = $i+1;
if ($date_arr[$j][6]) {
$j++;
}
}
foreach ($date_arr as $value) {
$html .= '<tr>';
foreach ($value as $v) {
if ($v) {
if ($v == $date['mday']) {
$html .= '<td><b>' . $v . '</b></td>';
} else {
$html .= '<td>' . $v . '</td>';
}
} else {
$html .= '<td> </td>';
}
}
$html .= '</tr>';
}
$html .= '</table>';
echo $html;
?>

下面這個(gè)也不錯(cuò),提示有錯(cuò)誤,思路清晰
復(fù)制代碼 代碼如下:
<?php
function calendar()
{
    if($_GET['ym'])
    {
        $year = substr($_GET['ym'],0,4);
        $month = substr($_GET['ym'],4,(strlen($_GET['ym'])-4));

        if($month>12)
        {
            $year += floor($month/12);
            $month = $month % 12;
        }
        if($year > 2030) $year = 2030;
        if($year < 1980) $year = 1980;
    }

    $year = isset($year) ? $year : date('Y');
    $month = isset($month) ? $month : date('n');

    if($year==date('Y') && $month==date('n')) $today = date('j');

    if($month-1 == 0)
        $prevmonth = ($year - 1)."12";
    else $prevmonth = $year.($month - 1);

    if($month+1 == 13)
        $nextmonth = ($year+1)."1";
    else $nextmonth = $year.($month+1);

    $prevyear = ($year - 1).$month;
    $nextyear = ($year + 1).$month;

    echo <<<VKN
        <table width="200" border="0" cellpadding="2" cellspacing="2">
  <tr>
    <td class="weekday"><a href="?ym=$prevyear"><<</a></td>
    <td class="normalday"><a href="?ym=$prevmonth"><</a></td>
    <td colspan="3" class="normalday">$year - $month</td>
    <td class="normalday"><a href="?ym=$nextmonth">></a></td>
    <td class="weekday"><a href="?ym=$nextyear">>></a></td>
  </tr>
  <tr>
    <td width="27" class="weekday">日</td>
    <td width="27" class="normalday">一</td>
    <td width="27" class="normalday">二</td>
    <td width="27" class="normalday">三</td>
    <td width="27" class="normalday">四</td>
    <td width="27" class="normalday">五</td>
    <td width="27" class="weekday">六</td>
  </tr>
VKN;
    $nowtime = mktime(0,0,0,$month,1,$year);//當(dāng)月1號(hào)轉(zhuǎn)為秒
    $daysofmonth = date(t,$nowtime);//當(dāng)月天數(shù)
    $weekofbeginday = date(w,$nowtime);//當(dāng)月第一天是星期幾
    $weekofendday = date(w,mktime(0,0,0,$month+1,0,$year));//當(dāng)月最后一天是星期幾
    $daysofprevmonth = date(t,mktime(0,0,0,$month,0,$year));//上個(gè)月天數(shù)

    $count = 1;//計(jì)數(shù)
    //列出上月后幾天
    for($i = 1 ; $i <= $weekofbeginday ; $i++)
        {
            echo     "<td class='othermonth'>".($daysofprevmonth-$weekofbeginday+$i)."</td>";
            $count++;
        }
    //當(dāng)月全部
    for($i = 1 ; $i <= $daysofmonth ; $i++)
        {
            $css = ($count%7==0 || $count%7==1)?"weekday":"normalday";
            if($i == $today) $css .= "today";

            echo     "<td class='".$css."'>".$i."</td>";
            if($count%7==0) echo "</tr><tr>";
            $count++;
        }
    //下月前幾天
    for ($i = 1;$i <= 6-$weekofendday;$i++)
        {
            echo     "<td class='othermonth'>".$i."</td>";
        }

    echo <<<VKN
          <tr>
    <td colspan="7"></td>
  </tr>
</table>
VKN;
}
?>
<!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=gb2312" />
<title>calendar</title>
<style type="text/css">
<!--
.weekday {
    font-size: 9pt;
    color: #FF0000;
    text-align: center;
}
.normalday {
    font-size: 9pt;
    color: #000000;
    text-align: center;
}
.weekdaytoday {
    font-size: 9pt;
    color: #FF0000;
    text-align: center;
    background-color: #FFD9D9;
    font-weight: bold;
}
.normaldaytoday {
    font-size: 9pt;
    color: #000000;
    text-align: center;
    background-color: #DDDDDD;
    font-weight: bold;
}
.othermonth {
    font-size: 9pt;
    font-style: italic;
    color: #999999;
    text-align: center;
}
-->
</style>
</head>

<body>
<?php calendar();?>
</body>
</html>

php技術(shù)php日歷[測(cè)試通過],轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 日本理论午夜中文字幕第一页 | 国产对白在线播放九色 | 欧美色爱综合网 | 小泽玛利亚一区二区三区免费 | 久久国产精品偷 | 爆操极品女神 | 久久夜色精品国产欧美 | 欧美三级图片 | 一级做a爰片久久毛片美女 一级做a爰片久久毛片人呢 | 久久有码中文字幕 | 怡红院视频网 | 99视频有精品视频免费观看 | 69热精品视频在线看影院 | 久久久久久亚洲精品中文字幕 | 麻豆91在线播放 | 日本一二三区免费 | 久久久久久一级毛片免费野外 | 天堂色在线 | 免费精品一区二区三区在线观看 | 色老板网站 | 欧美xxxxbbbb在线播放 | 色美女在线 | 成人春色在线观看免费网站 | 免费福利视频网址 | 成人欧美在线观看 | 久久九色综合九色99伊人 | 国产精品手机在线观看 | 婷婷夜夜躁天天躁人人躁 | 日韩中文字幕免费 | 四虎影视永久在线精品免费 | 中文字幕亚洲日韩无线码 | 中文字幕一二三四区2021 | 夜色资源站www国产在线观看 | 狠狠狠地在啪线香蕉 | 欧美色视频网站 | 国产在线精品一区二区三区不卡 | 手机看片www xiao2b cm | 美女张开腿让男人桶爽的免费动漫 | 中文字幕亚洲日韩无线码 | 国产精品久久久久久福利69堂 | 国产成人涩涩涩视频在线观看 |