/** * @param string $hisStart * @param string $hisEnd * @param int $range * @param string $format * * @return array */ function createHisRange($hisStart = ‘00:00:00‘, $hisEnd = ‘23:59:59‘, $range = 3600, $format = ‘H:00:00‘) { return array_map(function ($time) use ($format) { return date($format, $time); }, range(strtotime($hisStart), strtotime($hisEnd), $range)); } /** * @param $ymdStart * @param bool $ymdEnd * @param int $range * @param string $format * * @return array */ function createYmdRange($ymdStart, $ymdEnd = true, $range = 86400, $format = ‘Y-m-d‘) { return array_map(function ($time) use ($format) { return date($format, $time); }, range(strtotime($ymdStart), strtotime($ymdEnd), $range)); }
原文地址:http://blog.csdn.net/default7/article/details/40586131