def tz_to_utc(dt, tz, ignoretz=True):
    """Converts a datetime object from the specified timezone to a UTC datetime.

    :param tz: the timezone the datetime is currently in.  tz can be passed
        as a string or as a timezone object. (i.e. 'US/Central' or
        pytz.timezone('US/Central'), etc)
    :param ignoretz: will ignore the timezone portion of the datetime object and
        tzinfo will be None.
    :return: the datetime object by in UTC time.

    Examples:

    >>> tz_to_utc(datetime(2011, 11, 25, 9), 'US/Central')
    2011-11-25 15:00:00
    >>> tz_to_utc(datetime(2011, 11, 25, 9), pytz.timezone('US/Central'))
    2011-11-25 15:00:00
    >>> tz_to_utc(datetime(2011, 11, 25, 9), 'US/Central', False)
    2011-11-25 15:00:00+00:00

    """
    if isinstance(tz, string_types):
        tz = pytz.timezone(tz)

    dt = tz.localize(dt)
    dt = datetime.astimezone(dt, pytz.timezone('UTC'))

    if ignoretz:
        return dt.replace(tzinfo=None)
    return dt
Converts a datetime object from the specified timezone to a UTC datetime.

    :param tz: the timezone the datetime is currently in.  tz can be passed
        as a string or as a timezone object. (i.e. 'US/Central' or
        pytz.timezone('US/Central'), etc)
    :param ignoretz: will ignore the timezone portion of the datetime object and
        tzinfo will be None.
    :return: the datetime object by in UTC time.

    Examples:

    >>> tz_to_utc(datetime(2011, 11, 25, 9), 'US/Central')
    2011-11-25 15:00:00
    >>> tz_to_utc(datetime(2011, 11, 25, 9), pytz.timezone('US/Central'))
    2011-11-25 15:00:00
    >>> tz_to_utc(datetime(2011, 11, 25, 9), 'US/Central', False)
    2011-11-25 15:00:00+00:00