from datetime import datetime
import time


def timestamp(d=None):
    """ return timestamp from datetime in milliseconds """
    d = d or datetime.now()
    return int(time.mktime(d.timetuple())*1000)