Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Response.php

function Response::getExpires

Returns the value of the Expires header as a DateTime instance.

@final

1 call to Response::getExpires()
Response::getMaxAge in vendor/symfony/http-foundation/Response.php
Returns the number of seconds after the time specified in the response's Date header when the response should no longer be considered fresh.

File

vendor/symfony/http-foundation/Response.php, line 715

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function getExpires() : ?\DateTimeImmutable {
    try {
        return $this->headers
            ->getDate('Expires');
    } catch (\RuntimeException) {
        // according to RFC 2616 invalid date formats (e.g. "0" and "-1") must be treated as in the past
        return \DateTimeImmutable::createFromFormat('U', time() - 172800);
    }
}
RSS feed
Powered by Drupal