date_handler = lambda obj: obj.isoformat() if isinstance(obj, datetime.datetime
    ) or isinstance(obj, datetime.date) else None
json.dumps(datetime.datetime.now(), default=date_handler)
""""2010-04-20T20:08:21.634121\""""
JSON datetime between Python and JavaScript