There are several ways to achieve that by using Carbon. One of the easiest ways is using createFromTimeString
and between
methods:
$now = Carbon::now();
$start = Carbon::createFromTimeString('22:00');
$end = Carbon::createFromTimeString('08:00')->addDay();
if ($now->between($start, $end)) {
// ˉ\_(ツ)_/ˉ
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…