public function HeaderBag::getDate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/HeaderBag.php \Symfony\Component\HttpFoundation\HeaderBag::getDate()
Returns the HTTP header value converted to a date.
Parameters
string $key The parameter key:
\DateTime $default The default value:
Return value
null|\DateTime The parsed DateTime or the default value if the header does not exist
Throws
\RuntimeException When the HTTP header is not parseable
File
- vendor/
symfony/ http-foundation/ HeaderBag.php, line 206
Class
- HeaderBag
- HeaderBag is a container for HTTP headers.
Namespace
Symfony\Component\HttpFoundationCode
public function getDate($key, \DateTime $default = null) {
if (null === ($value = $this
->get($key))) {
return $default;
}
if (false === ($date = \DateTime::createFromFormat(DATE_RFC2822, $value))) {
throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value));
}
return $date;
}