Cake\Chronos\Traits\ComparisonTrait::wasWithinLast PHP Method

wasWithinLast() public method

Returns true this instance happened within the specified interval
public wasWithinLast ( string | integer $timeInterval ) : boolean
$timeInterval string | integer the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.
return boolean
    public function wasWithinLast($timeInterval)
    {
        $now = new static();
        $interval = $now->copy()->modify('-' . $timeInterval);
        $thisTime = $this->format('U');
        return $thisTime >= $interval->format('U') && $thisTime <= $now->format('U');
    }