Convert datetime objects to a timestamp for json.