from datetime import datetime


def timestamp(date_time):
    """Convert a date string to number of seconds since 1 Jan 1970 00:00 UTC
    date_time: e.g. "2017-10-04 20:17:34.286479-0500"
    or "2017-10-04 20:17:34-0500"
    """
    if date_time[-5] in "+-": date_time,TZ = date_time[:-5],date_time[-5:] 
    else: TZ = "+0000"
    if "." in date_time: format = "%Y-%m-%d %H:%M:%S.%f"
    else: format = "%Y-%m-%d %H:%M:%S"
    utc_dt = datetime.strptime(date_time,format)
    timestamp = (utc_dt - datetime(1970, 1, 1)).total_seconds()
    TZ_offset = int(TZ[0:3])*3600
    timestamp -= TZ_offset
    return timestamp