欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

本文實(shí)例講述了PHP實(shí)現(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); // 每個(gè)月的一號是星期幾
$days=date("t",$noe); //每個(gè)月的總天數(shù)
$day=date("d"); //獲取今天是幾號
$as=$year-1; //獲取上一年的年
$bs=$month-1; //獲取上個(gè)月
$bs=$month+1; // 獲取下個(gè)月
$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" ><<上個(gè)月</a></th>
     <th><?php echo $year."-".$month."-".$day ?></th>
     <th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" >下個(gè)月>></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>

運(yùn)行結(jié)果:

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

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

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

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

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

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

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

相關(guān)文章

最新評論