久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

基于ThinkPHP實(shí)現(xiàn)的日歷功能實(shí)例詳解

這篇文章主要介紹了基于ThinkPHP實(shí)現(xiàn)的日歷功能,結(jié)合實(shí)例形式詳細(xì)分析了基于thinkPHP實(shí)現(xiàn)日歷功能的相關(guān)界面布局、數(shù)據(jù)庫(kù)操作與日期時(shí)間運(yùn)算相關(guān)技巧,需要的朋友可以參考下

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

開發(fā)環(huán)境介紹

最新,閑來(lái)沒事,便開發(fā)了一款簡(jiǎn)單的日歷,來(lái)統(tǒng)計(jì)工作情況。為了開發(fā)便捷,使用ThinkPHP架構(gòu)。界面如下圖

基于ThinkPHP實(shí)現(xiàn)的日歷功能實(shí)例詳解

備注:每頁(yè)包含上一個(gè)月,當(dāng)前月,下一個(gè)月的日期,并用不同的顏色區(qū)分,如果某天工作了,便圈出來(lái)。
主要是以下兩個(gè)文件

重要文件描述

功能文件

基于ThinkPHP實(shí)現(xiàn)的日歷功能實(shí)例詳解

CalenDar.class.php主要負(fù)責(zé),獲取日歷詳細(xì)信息的,不涉及用戶數(shù)據(jù)操作。

代碼如下:

<?php
namespace Util;
class CalenDar{
  //上一個(gè)月信息
  private $lastYear=null;
  private $lastMonth=null;
  //當(dāng)前月信息
  private $curYear=null;
  private $curMonth=null;
  private $curWek=null;
  private $curDay=null;
  private $curDaySum=0;
  //下一個(gè)月月信息
  private $nextYear=null; //下一個(gè)月是哪一年
  private $nextMonth=null;//下一個(gè)月
  private $calendar=null;
  public function __construct($dateTime=null){
    if(isset($_get['yeal']) && is_numeric($_get['yeal'])){
      $this->curYear=$_get['yeal'];
    }else{
      $this->curYear=date('Y');
    }
    if(isset($_get['month']) && is_numeric($_get['month'])){
      $this->curMonth=$_get['month'];
    }else{
      $this->curMonth=date('n');
    }
    if(isset($_get['day']) && is_numeric($_get['day'])){
      $this->curDay=$_get['day'];
    }else{
      $this->curDay=date('j');
    }
    $this->init($dateTime);
    $this->createCalendar();
  }
  /**
  *初始化
  */
  public function init($dateTime=null){
    if(!empty($dateTime)){ //當(dāng)月
      $this->curYear=date('Y',strtotime($dateTime));
      $this->curMonth=date('n',strtotime($dateTime));
      $this->curDay=date('j',strtotime($dateTime));
    }
    $this->curWek=date('w',strtotime($this->curYear.'-'.$this->curMonth.'-1'));
    //上一個(gè)月
    $this->lastMonth=$this->curMonth-1; //上一個(gè)月
    $this->lastYear=$this->curYear; //上一個(gè)月屬于哪一年
    if($this->lastMonth<0){
      $this->lastMonth=12;
      $this->lastYear-=1;
    }
    //下一個(gè)月
    $this->nextMonth=$this->curMonth+1;//下一個(gè)月
    $this->nextYear=$this->curYear; //下一個(gè)月屬于哪一年
    if($this->nextMonth > 12){
      $this->nextMonth=1;
      $this->nextYear+=1;
    }
  }
  public function getCalendar(){
    return $this->calendar;
  }
  /**
  *創(chuàng)建日歷從周日 周一 周二 周三 周四 周五 周六,7*5方格,前面補(bǔ)上月后幾天,后面補(bǔ)下月開始幾天
  **/
  public function createCalendar(){
    //判斷當(dāng)月共計(jì)多少天
    $nextStr=$this->nextYear.'-'.$this->nextMonth.'-1 -1 days';
    $curDaySum=date('j',strtotime($nextStr));
    //判斷上一個(gè)月最后一天是多少號(hào)
    $lastStr=$this->curYear.'-'.$this->curMonth.'-1 -1 days';
    $lastDaySum=date('j',strtotime($lastStr));
    $prefixLId=$this->lastYear.'-'.$this->lastMonth;
    $prefixCId=$this->curYear.'-'.$this->curMonth;
    $prefixNId=$this->nextYear.'-'.$this->nextMonth;
    if($this->curWek == 0){
      $lastMonthSum=7; //需要添加上個(gè)月的$lastMonthSum天
    }else{
      $lastMonthSum=$this->curWek;
    }
    $lastMonthStart=$lastDaySum - $lastMonthSum+1;
    for($i=0,$j=1,$k=1;$i<42;$i++){
      $dateInfo=array();
      if($i<$lastMonthSum){ //上一個(gè)月
        $dateInfo['day']=$lastMonthStart + $i;
        $dateInfo['type']=1;
        $id=$prefixLId.'-'.$dateInfo['day'];
        $this->calendar[]=array('id'=>$id,
                    'info'=>$dateInfo);
      }else if($j > $curDaySum){//下一個(gè)月
        $id=$prefixNId.'-'.$k;
        $dateInfo['day']=$k;
        $dateInfo['type']=3;
        $this->calendar[]=array('id'=>$id,
                    'info'=>$dateInfo);
        $k++;
      }else{//本月
        $dateInfo['day']=$j;
        $dateInfo['type']=2;
        $this->calendar[]=array('id'=>($prefixCId.'-'.$j),
                    'info'=>$dateInfo);
        $j++;
        $this->curDaySum+=1;
      }
    }
  }
  public function getDayTime(){
    return $this->curYear.'-'.$this->curMonth.'-'.$this->curDay;
  }
  /**
  *獲取當(dāng)前月屬于哪個(gè)月
  **/
  public function getCurMonth(){
    return $this->curYear.'-'.$this->curMonth;
  }
  /**
  *獲取上一個(gè)月屬于哪個(gè)月
  **/
  public function getLastMonth(){
    return $this->lastYear.'-'.$this->lastMonth;
  }
  /**
  *獲取下一個(gè)月屬于哪個(gè)月
  **/
  public function getNextMonth(){
    return $this->nextYear.'-'.$this->nextMonth;
  }
  /**
  *判斷當(dāng)前月有多少天
  **/
  public function getCurDaySum(){
    return $this->curDaySum;
  }
}

【網(wǎng)站聲明】本站除付費(fèi)源碼經(jīng)過測(cè)試外,其他素材未做測(cè)試,不保證完整性,網(wǎng)站上部分源碼僅限學(xué)習(xí)交流,請(qǐng)勿用于商業(yè)用途。如損害你的權(quán)益請(qǐng)聯(lián)系客服QQ:2655101040 給予處理,謝謝支持。

相關(guān)文檔推薦

這篇文章主要介紹了ThinkPHP實(shí)現(xiàn)轉(zhuǎn)換數(shù)據(jù)庫(kù)查詢結(jié)果數(shù)據(jù)到對(duì)應(yīng)類型的方法,涉及thinkPHP模型類操作及針對(duì)源碼文件的相關(guān)修改方法,需要的朋友可以參考下
這篇文章主要介紹了thinkPHP中鉤子的使用方法,結(jié)合實(shí)例形式分析了thinkPHP鉤子的創(chuàng)建、添加、使用等相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下
這篇文章主要介紹了thinkphp5.0驗(yàn)證類的簡(jiǎn)單有效的使用方法,一起學(xué)習(xí)下。
本文主要講了thinkphp5.0版本中自定義驗(yàn)證規(guī)則的使用方法和一些注意事項(xiàng)。
這篇文章主要介紹了thinkPHP基于反射實(shí)現(xiàn)鉤子的方法,結(jié)合實(shí)例形式分析了php基于系統(tǒng)自帶的ReflectionClass、ReflectionMethod 類與函數(shù)實(shí)現(xiàn)鉤子功能的相關(guān)操作技巧,需要的朋友可以參考下
這篇文章主要介紹了thinkPHP通用控制器實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了thinkPHP針對(duì)數(shù)據(jù)庫(kù)的基本CURD操作方法的封裝實(shí)現(xiàn)技巧,需要的朋友可以參考下
主站蜘蛛池模板: 黄色免费看| 97伊人 | 国产视频久久久 | 久久久久国产精品 | 极品粉嫩国产48尤物在线播放 | 夜夜操天天操 | www.国产 | 激情av | 久久久久亚洲精品国产 | 国产精品久久久久久久久久久久 | 午夜在线影院 | 国产精品99久久久久久动医院 | 自拍偷拍亚洲视频 | 久久久国产一区二区三区 | 日韩精品一区二区三区视频播放 | 日日人人 | av大片在线观看 | 久久精品亚洲精品国产欧美 | 日韩不卡一区二区 | 国产激情片在线观看 | 欧美国产视频 | 91免费看片 | 91高清视频 | av网站在线看 | 亚洲影音先锋 | 天天插天天搞 | 亚洲协和影视 | 午夜日韩视频 | 一级做a爰片性色毛片 | 激情久久av一区av二区av三区 | 91精品国产91久久久久久丝袜 | av在线伊人| 亚洲精品一区二区三区中文字幕 | 午夜精品 | 一区二区在线不卡 | 一区2区 | 欧美aaa| 欧美精品一区二区三区四区五区 | .国产精品成人自产拍在线观看6 | 欧美精品乱码久久久久久按摩 | 欧美 日韩 亚洲91麻豆精品 |