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

Breadcrumb

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

function Cookie::expiresTimestamp

Converts expires formats to a unix timestamp.

3 calls to Cookie::expiresTimestamp()
Cookie::fromString in vendor/symfony/http-foundation/Cookie.php
Creates cookie from raw header string.
Cookie::withExpires in vendor/symfony/http-foundation/Cookie.php
Creates a cookie copy with a new time the cookie expires.
Cookie::__construct in vendor/symfony/http-foundation/Cookie.php

File

vendor/symfony/http-foundation/Cookie.php, line 152

Class

Cookie
Represents a cookie.

Namespace

Symfony\Component\HttpFoundation

Code

private static function expiresTimestamp(int|string|\DateTimeInterface $expire = 0) : int {
    // convert expiration time to a Unix timestamp
    if ($expire instanceof \DateTimeInterface) {
        $expire = $expire->format('U');
    }
    elseif (!is_numeric($expire)) {
        $expire = strtotime($expire);
        if (false === $expire) {
            throw new \InvalidArgumentException('The cookie expiration time is not valid.');
        }
    }
    return 0 < $expire ? (int) $expire : 0;
}

API Navigation

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