import time


def date2timestamp(datestr):
    """
    date: '%Y-%m-%d %H:%M:%S' to timestamp
    """
    try:
        ts = time.mktime(time.strptime(datestr, '%Y-%m-%d %H:%M:%S'))
    except Exception as e:
        raise e
    return int(ts)