in a magento store that i was building with newsletter option i enable confirmation before subscription from admin configuration. Users are getting confirmation link in mail.But my client want to set expiry of that confirmation  link.I was sure about this that magento provide this functionality or not.So i did a search and after some time i found a good solution.If you are also facing the same issue then you can use below steps :

1.  Add created_at field in newsletter_subscriber table.

2. Overwrite the following file

vendor/magento/module-newsletter/Model/Subscriber.php  to  Company/name/Model/Subscriber.php

Overited Subscriber.php file code

public function confirm($code) // existing function
    {
        $id = $this->getId();
        if ($this->validateConfirmLinkToken($id, $code)) {
            if ($this->getCode() == $code) {
                $this->setStatus(self::STATUS_SUBSCRIBED)
                    ->setStatusChanged(true)
                    ->save();
                $this->sendConfirmationSuccessEmail();
                return true;
            }

            return false;
        }
    }

    private function validateConfirmLinkToken($customerId, $code) //check validation for token
    {
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $messageManager = $objectManager->get('Magento\Framework\Message\ManagerInterface');
        if (empty($customerId) || $customerId < 0) {
            $this->_messageManager->addError('Sorry you have not rigts to access this page');
            return false;
        }
        if (!is_string($code) || empty($code)) {
            $params = ['fieldName' => 'code'];
            //$messageManager->addError('Sorry Your subscription confirmation code is not valid.');
            return false;
        }
        $dcode = $this->getCode();
        $dcreated_at = $this->getCreatedAt();
        if (trim($dcode) != trim($code)) {
            //$messageManager->addError('Sorry Your subscription confirmation code is mismatch.');
            return false;
        } elseif ($this->isConfirmationLinkTokenExpired($dcode, $dcreated_at)) {
            //$messageManager->addError('Sorry Your subscription confirmation code is expired.');
            return false;

        }

        return true;
    }

    public function isConfirmationLinkTokenExpired($dcode, $dcreated_at) // check expiration token
    {
        if (empty($dcode) || empty($dcreated_at)) {
            return true;
        }

        $expirationPeriod = '720';

        $currentTimestamp = (new \DateTime())->getTimestamp();
        $tokenTimestamp = (new \DateTime($dcreated_at))->getTimestamp();
        if ($tokenTimestamp > $currentTimestamp) {
            return true;
        }

        $hourDifference = floor(($currentTimestamp - $tokenTimestamp) / (60 * 60));
        if ($hourDifference >= $expirationPeriod) {
            return true;
        }

        return false;
    }

Hope it will help you too.