function Cookie::parseDate
1 call to Cookie::parseDate()
- Cookie::fromString in vendor/
symfony/ browser-kit/ Cookie.php - Creates a Cookie instance from a Set-Cookie header value.
File
-
vendor/
symfony/ browser-kit/ Cookie.php, line 199
Class
- Cookie
- Cookie represents an HTTP cookie.
Namespace
Symfony\Component\BrowserKitCode
private static function parseDate(string $dateValue) : ?string {
// trim single quotes around date if present
if (($length = \strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) {
$dateValue = substr($dateValue, 1, -1);
}
foreach (self::DATE_FORMATS as $dateFormat) {
if (false !== ($date = \DateTimeImmutable::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT')))) {
return $date->format('U');
}
}
// attempt a fallback for unusual formatting
if (false !== ($date = date_create_immutable($dateValue, new \DateTimeZone('GMT')))) {
return $date->format('U');
}
return null;
}