public function Response::setLastModified

Sets the Last-Modified HTTP header with a DateTime instance.

Passing null as value will remove the header.

@api

Parameters

\DateTime|null $date A \DateTime instance or null to remove the header:

Return value

Response

2 calls to Response::setLastModified()
BinaryFileResponse::setAutoLastModified in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php
Automatically sets the Last-Modified header according the file modification date.
Response::setCache in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php
Sets the response's cache headers (validation and/or expiration).

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php, line 832

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function setLastModified(\DateTime $date = null) {
  if (null === $date) {
    $this->headers
      ->remove('Last-Modified');
  }
  else {
    $date = clone $date;
    $date
      ->setTimezone(new \DateTimeZone('UTC'));
    $this->headers
      ->set('Last-Modified', $date
      ->format('D, d M Y H:i:s') . ' GMT');
  }
  return $this;
}