Home  >  Article  >  Backend Development  >  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
WBOYOriginal
2016-07-21 15:00:031109browse

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...
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