You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
748 B
PHP

<?php
namespace App\Services;
class TimeService
{
//根据时间段获取时间点
public function TimePointsArr($start_time,$end_time,$interval_time)
{
if (count(explode(':', $start_time)) == 1) $start_time = date('H:i:s', $start_time / 1000);
if (count(explode(':', $end_time)) == 1) $end_time = date('H:i:s', $end_time / 1000);
return $this->timeArr($start_time, $end_time, $interval_time);
}
function timeArr($start_time, $end_time, $interval_time, $arr = [])
{
if (strtotime($start_time) > strtotime($end_time)) return $arr;
$arr[] = date('H:i', strtotime($start_time));
return $this->timeArr(date('Y-m-d H:i:s', strtotime($start_time) + ($interval_time * 60)), $end_time, $interval_time, $arr);
}
}