def METHOD_NAME(d=None, milliseconds=False):
    """
    Converts a datetime object to a string with a timezone. If the datetime object
    does not have a timezone, it'll use the server's timezone.
    :param d: datetime object you want to convert to string
    :param milliseconds: add milliseconds to returned string
    :return:
    """
    if d is None:
        d = get_current_time()
    if not isinstance(d, datetime):
        raise TypeError(
            f"Invalid type. Expected datetime or datetime string, got {type(d)}."
        )
    if d.tzinfo is None:
        d = get_timezone().localize(d)
    if milliseconds:
        mlsec = d.strftime("%f")[0:3]
        answer = d.strftime(f"%Y-%m-%d %H:%M:%S.{mlsec}%z")
    else:
        answer = d.strftime("%Y-%m-%d %H:%M:%S%z")
    return answer