Home  >  Article  >  Backend Development  >  PHP gets the last day of the month function sharing, PHP gets the last day of the month_PHP tutorial

PHP gets the last day of the month function sharing, PHP gets the last day of the month_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:08:27861browse

PHP gets the last day of the month function sharing, php gets the last day of the month

A very simple and practical function, no more nonsense here, just provide the code

Copy code The code is as follows:

/**
* * Date-get the last day of the month
* @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;
}
/**
* * Date-whether it is a leap year
* @return int
​​*/
Public function is_leapyear($year) {
         return date('L', $year);
}

The above is the entire content of this code, I hope you guys like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/951638.htmlTechArticle Sharing function of getting the last day of the month in php, a very simple and practical function to get the last day of the month in php, not much nonsense here Yes, directly submit the code to copy the code as follows: /** * Day...
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