Home >Backend Development >PHP Tutorial >PHP simple calendar implementation program code_PHP tutorial

PHP simple calendar implementation program code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:49:261328browse

Regarding the application of calendar, it should be well reflected in independent blogs. Whether it is php's wp blog or ASP's z_blog blog, they all apply the calendar function, that is, log archiving. When we want When looking at previously published logs, just call up the log archive and you can view each article clearly.

Because I have recently been writing a calendar project function, I naturally thought of log archiving. In fact, it is not difficult to implement such a function. First, there must be a calendar form to visually display the calendar, and the time to process the date is handed in. Given programming code, such as PHP, if you want to read the previously written document, that is, turn the calendar forward, then you need to submit the calendar time, and then submit it to the form to display it.

Effect

The following is a PHP calendar function made by a novice. Here, the calendar function is written out in a file. The file is not very big and has comments. It is a simple principle function, and the receiving part is processed by PHP. , the display part uses a table. If you are doing a PHP calendar project, you can directly carry out secondary development and use it.

The code is as follows Copy code

//Strip date
date_default_timezone_set("Asia/Harbin");
$riqi=getdate();
$nian=$riqi['year'];
$yue=$riqi['mon'];
$ri=$riqi['mday'];
$hour=$riqi['hours'];
$min=$riqi['minutes'];
$miao=$riqi['seconds'];
//Form judgment
if(isset($_GET["yue"])){
$yue=intval($_GET["yue"]);
}
if(isset($_GET["nian"])){
$nian=intval($_GET["nian"]);
}
//How many days in a month
$tianshu=date('t',mktime(0,0,0,$yue,1,$nian));
//What day of the week is the first day of the month
$yuez=date('w',mktime(0,0,0,$yue,1,$nian));
$tian=0;
?>






 


















                                                                                           
             
                                                                          


Calendar Current time:
four
" align="center">
                                                                 If($h*$l<=$yuez && $h==1){
echo ' ';
             }elseif($tian<$tianshu){
                   echo ++$tian;                                    }else{
echo ' ';
         }
          ?>
        


Previous year
next year



If($yue-1<=0){
echo '<'.'12';
        }else{
echo '<'.($yue-1);
        }
​ ?>month

    
    
      if($yue+1>12){
       echo '1';
      }else{
       echo $yue+1;
      }?>月>
    

   
   

    

年:


    

月:


    
   

  

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632706.htmlTechArticle关于日历的应用,应该在独立博客上面能很好的体现出来吧,不管是 php 的 wp 博客,还是 ASP 的 z_blog 博客,都应用了日历的功能,那就是日...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn