src/DateRange.php
public static function forTimePeriod($time_period, Carbon $date_time)
    {
        $time_period = self::parseTimePeriod($time_period);
        switch ($time_period) {
            case self::HOUR:
                return static::between(
                    $date_time->copy()->minute(0)->second(0),
                    $date_time->copy()->minute(59)->second(59)
                );
            default:
                return static::between(
                    $date_time->copy()->{"startOf{$time_period}"}(),
                    $date_time->copy()->{"endOf{$time_period}"}()
                );
        }
    }
public static function forTimePeriod($time_period, Carbon $date_time)
    {
        $time_period = self::parseTimePeriod($time_period);
        switch ($time_period) {
            case self::HOUR:
                return static::between(
                    $date_time->copy()->minute(0)->second(0),
                    $date_time->copy()->minute(59)->second(59)
                );
            default:
                return static::between(
                    $date_time->copy()->{"startOf{$time_period}"}(),
                    $date_time->copy()->{"endOf{$time_period}"}()
                );
        }
    }
public static function forTimePeriod ( $ time_period , Carbon $ date_time ) { $ time_period = self :: parseTimePeriod ( $ time_period ) ; switch ( $ time_period ) { case self :: HOUR : return static :: between ( $ date_time -> copy ( ) -> minute ( 0 ) -> second ( 0 ) , $ date_time -> copy ( ) -> minute ( 59 ) -> second ( 59 ) ) ; default : return static :: between ( $ date_time -> copy ( ) -> { "startOf{$time_period}" } ( ) , $ date_time -> copy ( ) -> { "endOf{$time_period}" } ( ) ) ; } }
Gets a date range for a time period.

@param string $time_period
@param Carbon $date_time
@return static
Gets a date range for a time period .