Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-13 10:08:27
Original
942 people have browsed it

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...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template