src/Http/src/CookieJar.php
private function expirationToDateTime($expires): DateTimeInterface
    {
        if ($expires instanceof DateTimeImmutable) {
            return $expires;
        }

        if ($expires instanceof DateInterval) {
            $expires = (new DateTime)->add($expires);
        } elseif (is_string($expires) || is_int($expires)) {
            $expires = new DateTime(is_numeric($expires) ? '@' . $expires : $expires);
        }

        if (!$expires instanceof DateTimeInterface) {
            throw new InvalidArgumentException(
                'Invalid cookie expiration time. Cannot be converted to DateTimeInterface.'
            );
        }

        return new DateTimeImmutable($expires->format(DateTime::ISO8601), $expires->getTimezone());
    }
private function expirationToDateTime($expires): DateTimeInterface
    {
        if ($expires instanceof DateTimeImmutable) {
            return $expires;
        }

        if ($expires instanceof DateInterval) {
            $expires = (new DateTime)->add($expires);
        } elseif (is_string($expires) || is_int($expires)) {
            $expires = new DateTime(is_numeric($expires) ? '@' . $expires : $expires);
        }

        if (!$expires instanceof DateTimeInterface) {
            throw new InvalidArgumentException(
                'Invalid cookie expiration time. Cannot be converted to DateTimeInterface.'
            );
        }

        return new DateTimeImmutable($expires->format(DateTime::ISO8601), $expires->getTimezone());
    }
private function expirationToDateTime ( $ expires ) : DateTimeInterface { if ( $ expires instanceof DateTimeImmutable ) { return $ expires ; } if ( $ expires instanceof DateInterval ) { $ expires = ( new DateTime ) -> add ( $ expires ) ; } elseif ( is_string ( $ expires ) || is_int ( $ expires ) ) { $ expires = new DateTime ( is_numeric ( $ expires ) ? '@' . $ expires : $ expires ) ; } if ( ! $ expires instanceof DateTimeInterface ) { throw new InvalidArgumentException ( 'Invalid cookie expiration time. Cannot be converted to DateTimeInterface.' ) ; } return new DateTimeImmutable ( $ expires -> format ( DateTime :: ISO8601 ) , $ expires -> getTimezone ( ) ) ; }
Parses expiration time and returns valid DateTimeInterface implementation.

@param DateTimeInterface|DateInterval|string $expires
@return DateTimeInterface
@throws InvalidArgumentException
Parses expiration time and returns valid DateTimeInterface implementation .