Check if an entry with the given creation timestamp and lifetime is expired
@param $createTs The creation timestamp
@param $lifetime The lifetime in seconds
@return Boolean
178421
private function isExpired($createTs, $lifetime) {
    if ($lifetime === null) {
      return false;
    }
    $expireDate = (new \DateTime())->setTimeStamp($createTs);
    if (intval($lifetime)) {
      $expireDate = $expireDate->modify('+'.$lifetime.' seconds');
    }
    return $expireDate < new \DateTime();
  }
1242219
public function gc($maxLifetime)
    {
        try {
            return (bool) $this->db->from($this->table)
                    ->where($this->columns['expires'])->lt(time())
                    ->delete();
        } catch (PDOException $e) {
            return false;
        }
    }
412104
private function checkExpiration()
    {
        if (!$this->hasLifetime) {
            return;
        }

        if (!isset($this->payload['exp']) || !is_numeric($this->payload['exp'])) {
            return $this->state = self::INVALID;
        }

        if ($this->clockSkew <= (new \DateTime())->format('U') - $this->payload['exp']) {
            $this->state = self::EXPIRED;
        }
    }
645889
public function isAccessTokenExpired()
  {
    if (!$this->token || !isset($this->token['created'])) {
      return true;
    }

    // If the token is set to expire in the next 30 seconds.
    $expired = ($this->token['created']
        + ($this->token['expires_in'] - 30)) < time();

    return $expired;
  }
904938
private function updateExpireTag($tag, $lifetime = null)
    {
        try {
            if (isset($this->_hashmap[$tag])) {
                foreach (array_keys($this->_hashmap[$tag]) as $key) {
                    $value = $this->load($key);
                    if ($value) {
                        $this->save($key, $value, $lifetime, $tag);
                    }
                }

                return true;
            }
        } catch (\Exception $e) {
            $this->log('warning', \sprintf('Unable to update cache ttl for tag %s : %s', $tag, $e->getMessage()));

            return false;
        }

        return false;
    }
421022
public static function create($fid, $timestamp = null)
  {
    /**
     * @var $payload MarkDatePayload
     */
    $payload = parent::create($fid);
    $payload->timestamp = $timestamp;
    return $payload;
  }
52917
public function purge($lifetime = LibSessionsDomainEntitySession::MAX_LIFETIME, $guestOnly = true)
    {
        $past = time() - $lifetime;

        $query = $this->getQuery()->delete()->where('time < '.$past);

        if ($guestOnly) {
            $query->where('guest', '=', 1);
        }

        return (boolean) $this->getStore()->execute($query);
    }
190328
public function gcSession($maxLifetime)
	{
		$this->getDbConnection()->createCommand()
			->delete($this->sessionTableName,'expire<:expire',array(':expire'=>time()));
		return true;
	}
31909
public function isVisitTime($timestamp = null)
    {
        $timestamp = is_int($timestamp) ? $timestamp : time();
        foreach ($this->times as $time) {
            if ($this->isBetween($timestamp, $time['from'], $time['to'], 'Hi')) {
                return true;
            }
        }
        return empty($this->times);
    }
1087525
public function setLastVisit($timestamp = 'now')
	{
		$timestamp = new Date($timestamp);

		$query = $this->getQuery()
			->update($this->getTableName())
			->set(array('lastvisitDate' => $timestamp->toSql()))
			->whereEquals('id', $this->get('id'));

		return $query->execute();
	}
692963
protected function addExpirationCondition(
        QueryBuilder $query,
        int $expirationInSeconds,
        string $createdAtColumn
    ): QueryBuilder {
        $earliestExpired = $this->ignoreException(function () use ($expirationInSeconds) : DateTimeImmutable {
            return (new DateTimeImmutable())->sub(new DateInterval("PT{$expirationInSeconds}S"));
        });

        $query->andWhere($createdAtColumn . '>' . $this->createTypedParameter($query, $earliestExpired));

        return $query;
    }
238152
public function expired()
    {
        // Update if empty
        if (empty($this->entries)) {
            return true;
        }

        // Check timestamps
        if ($this->timestampManager) {
            return $this->timestampManager->check($this->getTimestamp());
        }

        return false;
    }
1085102
public static function hasInternalExpireTime($unserializedValue)
    {
        return (
            is_array($unserializedValue)
            && array_key_exists('v', $unserializedValue)
            && array_key_exists('s', $unserializedValue)
            && array_key_exists('ts', $unserializedValue)
        );
    }
137971
public function setExpireAt(int $timestamp): bool
    {
        return $this->handle->expireAt($this->name, $timestamp);
    }
256235
private function check_timestamp($timestamp)
    {
        if (!$timestamp) {
            throw new Twitter_OAuthException(
                'Missing timestamp parameter. The parameter is required'
            );
        }

        // verify that timestamp is recentish
        $now = time();
        if (abs($now - $timestamp) > $this->timestamp_threshold) {
            throw new Twitter_OAuthException(
                "Expired timestamp, yours $timestamp, ours $now"
            );
        }
    }
425308
private function _getFastLifetime($lifetime, $priority, $maxLifetime = null)
    {
        if ($lifetime <= 0) {
            // if no lifetime, we have an infinite lifetime
            // we need to use arbitrary lifetimes
            $fastLifetime = (int) (2592000 / (11 - $priority));
        } else {
            // prevent computed infinite lifetime (0) by ceil
            $fastLifetime = (int) ceil($lifetime / (11 - $priority));
        }

        if ($maxLifetime >= 0 && $fastLifetime > $maxLifetime) {
            return $maxLifetime;
        }

        return $fastLifetime;
    }
1063789
public function isCheckRequired()
    {
        if ($this->expired === false) {
            return false;
        }

        if ($this->cacheFile->exists()) {
            $expiryTimestamp = (int) $this->cacheFile->read();
        } else {
            $expiryTimestamp = 0;
        }
        $ts = Carbon::createFromTimestamp($expiryTimestamp + self::CHECK_INTERVAL);

        return $this->expired = $ts->isPast();
    }