public static function createFromFormat($format, $time, $timezone = null)
    {
        if (null === $timezone) {
            $timezone = self::getServerTimezone();
        }

        if (null === $timezone) {
            // This is necessary due to how native DateTime handles passing null for a timezone (it doesnt)
            $parent = parent::createFromFormat($format, $time);
        } else {
            $parent = parent::createFromFormat($format, $time, $timezone);
        }

        if (empty($parent)) {
            throw new TypeException('Could not create DateTime from the given format');
        }

        $datetime = new self('@' . $parent->getTimestamp());
        if (null !== $timezone) {
            $datetime->setTimezone($timezone);
        }

        return $datetime;
    }