@app.template_filter('date_to_millis')
def date_to_millis(d):
    """Converts a datetime object to the number of milliseconds since the unix epoch."""
return int(time.mktime(d.timetuple())) * 1000
Converting date from Python to Javascript