from datetime import datetime
import pytz


def datetime_to_epoch(dt):
    """
    return the epcoh value of date time object timestamp
    NOTE: doctest for specific timezone.
    >>> datetime_to_epoch(datetime(1970, 1, 1, tzinfo=pytz.utc))
    0
    """
    try:
        # for python 3
        return int(1000 * dt.timestamp())
    except:
        # for python 2, borrow from python source code: https://hg.python.org/cpython/file/3.3/Lib/datetime.py#l1428
        _EPOCH = datetime(1970, 1, 1, tzinfo=pytz.utc)
        return 1000 * ((dt - _EPOCH).total_seconds())