import time
import calendar


def get_timestamp_from_datetime(dt, is_local_time=True):
    """Get an epoch timestamp from a UTC datetime.

    Ref: https://docs.python.org/2/library/calendar.html#calendar.timegm
         http://stackoverflow.com/a/8778548/257924"""
    if is_local_time:
        timestamp = time.mktime(dt.timetuple())  # DO NOT USE IT WITH UTC DATE
    else:
        timestamp = calendar.timegm(dt.timetuple())
    return timestamp