LdapTools\AttributeConverter\ConvertGeneralizedTime::fromLdap PHP Method

fromLdap() public method

public fromLdap ( $timestamp )
    public function fromLdap($timestamp)
    {
        preg_match("/^(\\d+).?0?(([+-]\\d\\d)(\\d\\d)|Z)\$/i", $timestamp, $matches);
        if (!isset($matches[1]) || !isset($matches[2])) {
            throw new \RuntimeException(sprintf('Invalid timestamp encountered: %s', $timestamp));
        }
        $tz = strtoupper($matches[2]) == 'Z' ? 'UTC' : $matches[3] . ':' . $matches[4];
        return new \DateTime($matches[1], new \DateTimeZone($tz));
    }