Passing null as value will remove the header.
public setLastModified ( DateTime $date = null ) : |
||
$date | DateTime | A \DateTime instance or null to remove the header |
return |
use Symfony\Component\HttpFoundation\Response; $response = new Response(); $response->setLastModified(new \DateTime());
use Symfony\Component\HttpFoundation\Response; $lastModified = new \DateTime('2020-01-01 00:00:00'); $response = new Response(); $response->setLastModified($lastModified);
use Symfony\Component\HttpFoundation\Response; $lastModified = 1577836800; // Jan 1, 2020 00:00:00 UTC $response = new Response(); $response->setLastModified($lastModified);These examples demonstrate how to use the setLastModified method to set the Last-Modified response header in PHP with the Symfony HTTP Foundation library. This library provides a convenient way to work with HTTP requests and responses in PHP.
public setLastModified ( DateTime $date = null ) : |
||
$date | DateTime | A \DateTime instance or null to remove the header |
return |