程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP綜合 >> php獲取當月最後一天函數分享

php獲取當月最後一天函數分享

編輯:PHP綜合

非常簡單實用的函數,這裡就不多廢話了,直接奉上代碼

復制代碼 代碼如下:
/**
     *    日期-獲取當月最後一天
     *  @return int
     */
    public function get_lastday() {
        if($this->month==2) {
            $lastday = $this->is_leapyear($this->year) ? 29 : 28;
        } elseif($this->month==4 || $this->month==6 || $this->month==9 || $this->month==11) {
            $lastday = 30;
        } else {
            $lastday = 31;
        }
        return $lastday;
    }
    /**
     *    日期-是否是閏年
     *  @return int
     */
    public function is_leapyear($year) {
        return date('L', $year);
    }

以上就是本代碼的全部內容,希望小伙伴們喜歡。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved