def time2str(t, fmt='%Y-%m-%d %H:%M:%S', microsec=False):
    """ Convert a pandas Timestamp to a string

        See https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior for conversion
    """
    fmt = fmt + '.%f' if microsec is True else fmt
    return t.strftime(fmt)
    #return t.strftime(fmt)