function Response::setExpires
Sets the Expires HTTP header with a DateTime instance.
Passing null as value will remove the header.
@final
Return value
$this
File
-
vendor/
symfony/ http-foundation/ Response.php, line 734
Class
- Response
- Response represents an HTTP response.
Namespace
Symfony\Component\HttpFoundationCode
public function setExpires(?\DateTimeInterface $date) : static {
if (null === $date) {
$this->headers
->remove('Expires');
return $this;
}
$date = \DateTimeImmutable::createFromInterface($date);
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$this->headers
->set('Expires', $date->format('D, d M Y H:i:s') . ' GMT');
return $this;
}