最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP實現(xiàn)的日歷功能示例

 更新時間:2018年09月01日 14:44:36   作者:Json______  
這篇文章主要介紹了PHP實現(xiàn)的日歷功能,涉及php針對日期時間的簡單運算與輸出顯示相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了PHP實現(xiàn)的日歷功能。分享給大家供大家參考,具體如下:

<?php
/*
 * Created by PhpStorm.
 * User: admin
 */
header("Content-Type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
$a=@$_GET["a"];
$b=@$_GET["b"];
if($a){
  $a=$a;
}else{
  $a=date('y');
}
if($b){
  $b=$b;
}else{
  $b=date('m');
}
$noe=mktime(0,0,0,$b,1,$a); //獲取當(dāng)前的月的一號
$year=date("Y",$noe); //當(dāng)前的年
$month=date("m",$noe); //當(dāng)前的月
$week=date("w",$noe); // 每個月的一號是星期幾
$days=date("t",$noe); //每個月的總天數(shù)
$day=date("d"); //獲取今天是幾號
$as=$year-1; //獲取上一年的年
$bs=$month-1; //獲取上個月
$bs=$month+1; // 獲取下個月
$as=$year+1; //獲取下一年
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>日歷</title>
  <style>
    table{
      border: 1px solid #050;
    }
    table th{
      background:#000;
      color:#fff;
      border: 2px solid #050;
    }
  </style>
</head>
<body>
 <table cellpadding="0" cellspacing="0">
   <tr>
     <th><a href="?a=<?php echo $as; ?>" rel="external nofollow" rel="external nofollow" ><<上一年</a></th>
     <th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" ><<上個月</a></th>
     <th><?php echo $year."-".$month."-".$day ?></th>
     <th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" >下個月>></a></th>
     <th><a href="?a=<?php echo $as; ?>" rel="external nofollow" rel="external nofollow" >下一年>></a></th>
   </tr>
   <tr>
     <th>星期日</th>
     <th>星期一</th>
     <th>星期二</th>
     <th>星期三</th>
     <th>星期四</th>
     <th>星期五</th>
     <th>星期六</th>
   </tr>
  <tr>
    <?php
    for($i=0;$i<$week;$i++){
      echo "<td>&nbsp;</td>"; //獲取當(dāng)月一號前面的空格
    }
    for($k=1;$k<=$days;$k++){
      if($k==$day){
        echo "<th>".$k."</th>"; //輸出今天是幾號
      }else{
        echo "<td>".$k."</td>"; //輸出當(dāng)月天數(shù)
      }
      if(($k+$week)%7==0){
        echo "<tr></tr>"; // 一周七天換行
      }
    }
    ?>
  </tr>
 </table>
</body>
</html>

運行結(jié)果:

PS:這里再為大家推薦幾款時間及日期相關(guān)工具供大家參考:

在線日期/天數(shù)計算器:
http://tools.jb51.net/jisuanqi/date_jisuanqi

在線日期計算器/相差天數(shù)計算器:
http://tools.jb51.net/jisuanqi/datecalc

在線日期天數(shù)差計算器:
http://tools.jb51.net/jisuanqi/onlinedatejsq

Unix時間戳(timestamp)轉(zhuǎn)換工具:
http://tools.jb51.net/code/unixtime

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php日期與時間用法總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP基本語法入門教程》、《PHP運算與運算符用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家PHP程序設(shè)計有所幫助。

相關(guān)文章

最新評論

噶尔县| 海林市| 德格县| 云梦县| 砀山县| 汕头市| 平山县| 齐齐哈尔市| 门头沟区| 临汾市| 衢州市| 镇巴县| 鄂伦春自治旗| 丰原市| 来凤县| 诏安县| 崇明县| 宝清县| 正定县| 乌恰县| 凌源市| 搜索| 金华市| 泊头市| 白玉县| 绥阳县| 屏南县| 巴里| 雷波县| 屏山县| 依安县| 晴隆县| 徐汇区| 阿克陶县| 陵川县| 绵阳市| 海晏县| 江达县| 象山县| 揭东县| 南平市|