public function withExpiry(\DateTimeInterface $date): self
    {
        $new = clone $this;

        if ($date instanceof \DateTimeImmutable) {
            $new->expiry = $date;
        } elseif ($date instanceof \DateTime) {
            $new->expiry = \DateTimeImmutable::createFromMutable($date);
        } else {
            $new->expiry = new \DateTimeImmutable("@" . $date->getTimestamp());
        }

        return $new;
    }
public function withExpiry(\DateTimeInterface $date): self
    {
        $new = clone $this;

        if ($date instanceof \DateTimeImmutable) {
            $new->expiry = $date;
        } elseif ($date instanceof \DateTime) {
            $new->expiry = \DateTimeImmutable::createFromMutable($date);
        } else {
            $new->expiry = new \DateTimeImmutable("@" . $date->getTimestamp());
        }

        return $new;
    }
public function withExpiry ( \ DateTimeInterface $ date ) : self { $ new = clone $ this ; if ( $ date instanceof \ DateTimeImmutable ) { $ new -> expiry = $ date ; } elseif ( $ date instanceof \ DateTime ) { $ new -> expiry = \ DateTimeImmutable :: createFromMutable ( $ date ) ; } else { $ new -> expiry = new \ DateTimeImmutable ( "@" . $ date -> getTimestamp ( ) ) ; } return $ new ; }
Applies the given expiry to the cookie.

@param \DateTimeInterface $date

@return self Cloned instance with the specified operation applied.

@see self::withMaxAge()
@see self::withoutExpiry()

@link https://tools.ietf.org/html/rfc6265#section-5.2.1
Applies the given expiry to the cookie .