"{$this->date} {$time}", "timestamp" => strtotime("{$this->date} {$time}") ]; }, $this->times); return collect($sameTimes); } /** * 签到时段 * @param int $diff 多长未签到算失效(秒) * @return array */ public function atSection($diff = 3600) { $start = ""; $end = ""; $array = []; foreach ($this->times as $time) { $time = preg_replace("/:00$/", "", $time); if (empty($start)) { $start = $time; continue; } if (empty($end)) { $end = $time; continue; } if (strtotime("2022-01-01 {$time}") - strtotime("2022-01-01 {$end}") > $diff) { $array[] = [$start, $end]; $start = $time; $end = ""; continue; } $end = $time; } if ($start) { $array[] = [$start, $end]; } return $array; } }