How can I change the default Django date template format?

bash- picture bash- · Oct 12, 2011 · Viewed 202.2k times · Source

I have dates in ISO 8601 format in the database, %Y-%m-%d. However, when the date is passed on to the template, it comes out as something like Oct. 16, 2011.

Is there a way that I can manipulate the format to whatever I want?

Answer

medmunds picture medmunds · Oct 13, 2011

Within your template, you can use Django's date filter. E.g.:

<p>Birthday: {{ birthday|date:"M d, Y" }}</p>

Gives:

Birthday: Jan 29, 1983

More formatting examples in the date filter docs.