Neos\Flow\Http\Response::setNow PHP Метод

setNow() публичный Метод

This date / time is used internally for comparisons in order to determine the freshness of this response. By default this DateTime object is set automatically through dependency injection, configured in the Objects.yaml of the Flow package. Unless you are mocking the current time in a test, there is probably no need to use this function. Also note that this method must be called before any of the Response methods are used and it must not be called a second time.
public setNow ( DateTime $now ) : void
$now DateTime The current point in time
Результат void
    public function setNow(\DateTime $now)
    {
        $this->now = clone $now;
        $this->now->setTimezone(new \DateTimeZone('UTC'));
        $this->headers->set('Date', $this->now);
    }

Usage Example

 /**
  * RFC 2616 / 14.21 (Expires)
  *
  * @test
  */
 public function makeStandardsCompliantRemovesMaxAgeDireciveIfExpiresHeaderIsPresent()
 {
     $now = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 22 May 2012 12:00:00 GMT');
     $later = \DateTime::createFromFormat(DATE_RFC2822, 'Wed, 23 May 2012 12:00:00 GMT');
     $request = Request::create(new Uri('http://localhost'));
     $response = new Response();
     $response->setNow($now);
     $response->setMaximumAge(60);
     $response->setExpires($later);
     $response->makeStandardsCompliant($request);
     $this->assertSame(null, $response->getHeaders()->getCacheControlDirective('max-age'));
     $this->assertEquals($later, $response->getExpires());
 }