I'm using Django to serve up some XML. Part of the requirements is that my dates are formatted as follows: 1969-12-31T18:33:28-06:00
How can I output a DateField in Django in that format?
Python django format date dd/mm/yyyy And, because the format is dd/mm/yyyy, we must use a slash to separate the date, month and year. To separate the day from the month and the month from the year in a date notation we use DateSeparator.
django default date to be in format %d-%m-%Y.
New in Django 1.2, there is a template tag that will output what you wish:
{{ value|date:"c"}}
From the Django template documentation:
c | ISO 8601 Format | 2008-01-02T10:30:00.000123
Technically, this closer to W3-DTF, but close enough
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With