PHP:获取指定日期所在月的开始日期与结束日期
/** * 获取指定日期所在月的开始日期与结束日期 * @param string $date * @param boolean 为true返回开始日期,否则返回结束日期 * @return array * @author zyb <zyb.allwell@gmail.com> * @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; } }