import time


def epochtime_to_string(epochtime=None, use_second=False):
    """
    Given an epoch time (seconds since 1/1/1970), return a string useful
    as a plot title. Set the use_second flag to also include seconds in
    the string.
    """
    try:
        if use_second:
            time_string = time.strftime('%m/%d/%Y %H:%M:%S UTC',
                                        time.gmtime(epochtime))
        else:
            time_string = time.strftime('%m/%d/%Y %H:%M UTC',
                                        time.gmtime(epochtime))
    except:
        time_string = ''
    return time_string