Home > php教程 > php手册 > body text

两个php日期控制类实例

WBOY
Release: 2016-06-06 20:16:01
Original
1032 people have browsed it

这篇文章主要介绍了两个php日期控制类,包含了详细的样式控制与使用方法,非常具有实用价值,需要的朋友可以参考下

本文实例讲述了两个php日期控制类。分享给大家供大家参考。具体分析如下:

由于工作需要我找了二个时间日期控制,这个不用js只要php实现的,因为要带参考查询操作,感兴趣的朋友可以参考一下,我自己用的是第二个,所以第二个己作了修改.

实例一,代码如下:

复制代码 代码如下:

class Calendar
{
 var $month;
 var $year;
 
    function __construct($year,$month)
    {
     $this->year=$year;
  $this->month=$month;
 }
 
 function endday()
 {
  $daydate=date("d",mktime(0,0,0,$this->month,35,$this->year));
  $endday=35-$daydate;
  return $endday;
 }
 
 function oneday_week()
 {
  $oneday_week=date("w",mktime(0,0,0,$this->month,1,$this->year));
  return $oneday_week;
 }
 
 function title_link()
 {
  if(!isset($this->month) && !isset($this->year))
  {
   $this->year  = date("Y");
   $this->month = date("m");
        }
  
  $lastmonth=$this->month-1;
  $nextmonth=$this->month+1;
  $lastyear=$this->year;
  $nextyear=$this->year;
 
        if($this->month         {
         $lastmonth=12;
   $nextmonth=$this->month+1;
   $lastyear=$this->year-1;
   $nextyear=$this->year;
  }
        elseif ($this->month >= 12) 
        {
         $lastmonth=$this->month-1;
         $nextmonth=1;
   $lastyear=$this->year;
   $nextyear=$this->year+1;
        }
 
        $str ="

";
  $str.="
".$this->year."--".$this->month."
";
  $str.="";
  return $str;
 }
 
 function Show_Calendar()
 {
        echo "".$this->title_link()."";
        $weekarray=array("日","一","二","三","四","五","六");
        
        for($k=0;$k         {
         echo "";
        }
        echo "";
        
        for($i=0;$i         {
         echo "";
         for($j=1;$j          {
     $math=( $j - $this->oneday_week() ) + 7 * $i;
    
          echo "";
         }    
         echo "";     
        }
  echo "
".$weekarray[$k]."
";
    
          if($math endday() and $math>=1)
     {
   echo $math;
     }
    
         echo "
";
 }
}
$calendar=new Calendar($_GET['year'],$_GET['month']);
$calendar->month=$_GET['month'];
$calendar->year=$_GET['year'];
$calendar->Show_Calendar();
?>
实例二,代码如下:

复制代码 代码如下:

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template