getDate() public method

Returns the HTTP header value converted to a date.
public getDate ( string $key, DateTime $default = null ) : null | DateTime
$key string The parameter key
$default DateTime The default value
return null | DateTime The parsed DateTime or the default value if the header does not exist
 /**
  * @expectedException \RuntimeException
  */
 public function testGetDateException()
 {
     $bag = new HeaderBag(array('foo' => 'Tue'));
     $headerDate = $bag->getDate('foo');
 }
Example #2
0
 /**
  * Returns the Last-Modified HTTP header as a DateTime instance.
  *
  * @return \DateTime A DateTime instance
  */
 public function getLastModified()
 {
     return $this->headers->getDate('LastModified');
 }