I am trying to generate JSON date string for yesterday. I am not sure how to generate it in RFC 3339 format. from datetime import date, timedelta yesterday = date.today() - timedelta(1) def dthandler(obj): return obj.isoformat() with io.open('out/test.json', 'w', encoding='utf-8') as outfile: json.dump(rdata, outfile, indent=4, sort_keys=True, default=dthandler) which format the date as: "Date": "2012-12-04", How can I write the formatter function to get RfC 3339 format? I use Python 3.x. Continue reading...