You are here

public function Response::setLastModified in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Response.php \Symfony\Component\HttpFoundation\Response::setLastModified()

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

Passing null as value will remove the header.

Parameters

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

Return value

Response

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

File

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

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;
}