Home > Backend Development > PHP Tutorial > How to use PHP to get the start date and end date of the month on a specified date_PHP Tutorial

How to use PHP to get the start date and end date of the month on a specified date_PHP Tutorial

WBOY
Release: 2016-07-21 15:00:03
Original
1172 people have browsed it

Copy code The code is as follows:

/**
* Get the start date and end date of the month where the specified date is located
* @param string $date
* @param boolean returns the start date if true, otherwise returns the end date
* @return array
* @access private
*/
private function getMonthRange( $date, $returnFirstDay = true ) {
$timestamp = strtotime( $date );
if ( $returnFirstDay ) {
$monthFirstDay = date( 'Y-m-1 00:00:00', $timestamp );
return $monthFirstDay;
} else {
            $mdays = date( 't', $timestamp ); $timestamp );
return $monthLastDay;
}
}

http://www.bkjia.com/PHPjc/328099.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328099.htmlTechArticleCopy code The code is as follows: /** * Get the start date and end date of the month on the specified date* @param string $date * @param boolean returns the start date if true, otherwise returns the end date...
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