php通过传递一个区间获取两个时间字符串之间的时间跨度

php Get Time Spans Between Two Time Strings by Passing an Interval

for example There is a function

getTimeSpans('08:00 AM', '01:00PM','15 minutes');

This function must return all time strings between 08:00AM and 01:00PM with difference of 15 minutes

简单练习一下这个核心PHP代码

function getTimeSpans($start, $end, $interval){
     $intervals = array();
     $s = date('h:i A', strtotime($start));
     $e = date('h:i A', strtotime($end));
     while($s != $e)
     {
       array_push($intervals, $s);
       $s = date('h:i A', strtotime($s.' '.$interval));
     }
    return $intervals;
}

    print_r(getTimeSpans('08:00AM', '09:00AM', '10 minutes'));