Eren Süleymanoğlu Eren Süleymanoğlu - 1 year ago 80
Python Question

(Django) how to get month name?

I have a query like below:

today =
month = today.month
print month

and it outputs:


I want to display the month name like "March". What should I do?

Answer Source

use the datetime string formatting method, e.g.

>>> today.strftime('%B')

for more info, and a full list of formatting codes, see the python datetime docs

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download