復制代碼 代碼如下:
/**
* 獲取指定日期所在月的開始日期與結束日期
* @param string $date
* @param boolean 為true返回開始日期,否則返回結束日期
* @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 );
$monthLastDay = date( 'Y-m-' . $mdays . ' 23:59:59', $timestamp );
return $monthLastDay;
}
}