dateTime->setTimezone(new DateTimeZone('UTC')); return $dt->format('ymdHis\\Z'); } protected static function decodeFromDER(Identifier $identifier, string $data, int &$offset): ElementBase { $idx = $offset; $length = Length::expectFromDER($data, $idx)->intLength(); $str = mb_substr($data, $idx, $length, '8bit'); $idx += $length; if (preg_match(self::REGEX, $str, $match) !== 1) { throw new DecodeException('Invalid UTCTime format.'); } [, $year, $month, $day, $hour, $minute, $second] = $match; $time = $year . $month . $day . $hour . $minute . $second . self::TZ_UTC; $dt = DateTimeImmutable::createFromFormat('!ymdHisT', $time, new DateTimeZone('UTC')); if ($dt === false) { throw new DecodeException('Failed to decode UTCTime'); } $offset = $idx; return self::create($dt); } }