import time


def epoch(value):
    """
    Convert datetime to unix epoch time.
    Alternatively you can you this {{ my_date|date:"U" }}

    :param value: datetime instance
    :return: int
    """
    try:
        return int(time.mktime(value.timetuple()) * 1000)
    except AttributeError:
        return ''