<?php /** * @param year 年份 */ function getMonthByDate($year) { // $year = '2019'; $yeararr = []; $month = []; for ($i=1; $i <=12 ; $i++) { $yeararr[$i] = $year.'-'.$i; } foreach ($yeararr as $key => $value) { $timestamp = strtotime($value ); $start_time = date( 'Y-m-1 00:00:00', $timestamp ); $mdays = date( 't', $timestamp ); $end_time = date( 'Y-m-' . $mdays . ' 23:59:59', $timestamp ); $month[$key]['start_time'] = strtotime($start_time); $month[$key]['end_time'] = strtotime($end_time); } return $month; } ?>
本文结束