How do I turn a python datetime into a string, with readable format date?

datetime, python, string-formatting

Solution

The datetime class has a method strftime. The Python docs documents the different formats it accepts: strftime() and strptime() Behavior

For this specific example, it would look something like:

my_datetime.strftime("%B %d, %Y")

Problem

``` t = e['updated_parsed'] dt = datetime.datetime(t[0],t[1],t[2],t[3],t[4],t[5],t[6] print dt >>>2010-01-28 08:39:49.000003 ``` How do I turn that into a string?: ``` "January 28, 2010" ```

Original source