src/Certificate.php
/**
     * Check whether certificate valid for given date.
     * If DateTime not provided, validation for current date will be performed.
     *
     * @param DateTime|null $subjectDate
     * @return Verification
     * @throws Exception
     */
Check whether certificate valid for given date.
If DateTime not provided, validation for current date will be performed.

@param DateTime|null $subjectDate
@return Verification
@throws Exception
Check whether certificate valid for given date . If DateTime not provided validation for current date will be performed . @param DateTime|null $subjectDate @return Verification @throws Exception
public function verifyDate(?DateTime $subjectDate = null): Verification
    {
        if (is_null($subjectDate)) {
            $subjectDate = new DateTime();
        }
        $startDate = DateTime::createFromFormat('Y-m-d\TH:i:sP', $this->getValidNotBefore());
        $endDate = DateTime::createFromFormat('Y-m-d\TH:i:sP', $this->getValidNotAfter());
        if ($endDate->getTimestamp() < $subjectDate->getTimestamp()) {
            return new Verification(Verification::CRT_NOT_VALID_AFTER, false, $this);
        }
        if ($startDate->getTimestamp() >= $subjectDate->getTimestamp()) {
            return new Verification(Verification::CRT_NOT_VALID_BEFORE, false, $this);
        }
        return new Verification(Verification::CRT_DATE_VALID, true);
    }
public function verifyDate ( ? DateTime $ subjectDate = null ) : Verification { if ( is_null ( $ subjectDate ) ) { $ subjectDate = new DateTime ( ) ; } $ startDate = DateTime :: createFromFormat ( 'Y-m-d\TH:i:sP' , $ this -> getValidNotBefore ( ) ) ; $ endDate = DateTime :: createFromFormat ( 'Y-m-d\TH:i:sP' , $ this -> getValidNotAfter ( ) ) ; if ( $ endDate -> getTimestamp ( ) < $ subjectDate -> getTimestamp ( ) ) { return new Verification ( Verification :: CRT_NOT_VALID_AFTER , false , $ this ) ; } if ( $ startDate -> getTimestamp ( ) >= $ subjectDate -> getTimestamp ( ) ) { return new Verification ( Verification :: CRT_NOT_VALID_BEFORE , false , $ this ) ; } return new Verification ( Verification :: CRT_DATE_VALID , true ) ; }
Check whether certificate valid for given date.
Check whether certificate valid for given date .
// Если нам не передали дату, то мы должны проверить на текущую дату // Если время окончания меньше, еще не наступило или прям совпадает с текущей датой // Если время начала действия сертификата еще не наступило