public function toASN1(): TimeType
    {
        $dt = $this->_dt;
        switch ($this->_type) {
            case Element::TYPE_UTC_TIME:
                return new UTCTime($dt);
            case Element::TYPE_GENERALIZED_TIME:
                // GeneralizedTime must not contain fractional seconds
                // (rfc5280 4.1.2.5.2)
                if ($dt->format("u") != 0) {
                    // remove fractional seconds (round down)
                    $dt = self::_roundDownFractionalSeconds($dt);
                }
                return new GeneralizedTime($dt);
        }
        throw new \UnexpectedValueException(
            "Time type " . Element::tagToName($this->_type) . " not supported.");
    }
public function toASN1(): TimeType
    {
        $dt = $this->_dt;
        switch ($this->_type) {
            case Element::TYPE_UTC_TIME:
                return new UTCTime($dt);
            case Element::TYPE_GENERALIZED_TIME:
                // GeneralizedTime must not contain fractional seconds
                // (rfc5280 4.1.2.5.2)
                if ($dt->format("u") != 0) {
                    // remove fractional seconds (round down)
                    $dt = self::_roundDownFractionalSeconds($dt);
                }
                return new GeneralizedTime($dt);
        }
        throw new \UnexpectedValueException(
            "Time type " . Element::tagToName($this->_type) . " not supported.");
    }
public function toASN1 ( ) : TimeType { $ dt = $ this -> _dt ; switch ( $ this -> _type ) { case Element :: TYPE_UTC_TIME : return new UTCTime ( $ dt ) ; case Element :: TYPE_GENERALIZED_TIME : // GeneralizedTime must not contain fractional seconds // (rfc5280 4.1.2.5.2) if ( $ dt -> format ( "u" ) != 0 ) { // remove fractional seconds (round down) $ dt = self :: _roundDownFractionalSeconds ( $ dt ) ; } return new GeneralizedTime ( $ dt ) ; } throw new \ UnexpectedValueException ( "Time type " . Element :: tagToName ( $ this -> _type ) . " not supported." ) ; }
Generate ASN.1.

@throws \UnexpectedValueException
@return TimeType
Generate ASN . 1 .