Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Cookie.php

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\BrowserKit

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal