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