5๐
If you look under date in the Django documentation youโll see that a variety of formats for the date are supported. Basically in a template you need:
{{ value|date:"some format string" }}
where the format string can be one of the ones defined under date on the page above or one of the custom ones defined under the now function (which includes ISO 8601 format) which is also on the page linked to above. Iโm assuming that when you output to xml you do so in a similar way to a template for a normal web page.
Update (August 2014)
As indicated in another answer by Edgar R, as of version 1.2 onwards you can now use a built in switch to output the date in ISO 8601 format using format string: c
47๐
Introduced 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
- [Django]-How to set and get cookies in Django?
- [Django]-Restricting access to private file downloads in Django
- [Django]-OperationalError, no such column. Django
13๐
Since Django is written in Python,
http://docs.python.org/library/datetime.html#datetime.datetime.isoformat
datetime(2002, 12, 25, tzinfo=TZ()).isoformat()
- [Django]-TypeError: ManyRelatedManager object is not iterable
- [Django]-Unable to connect to server: PgAdmin 4
- [Django]-Django queryset get exact manytomany lookup
1๐
Check out these docs:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#date
http://docs.djangoproject.com/en/dev/ref/settings/#setting-DATE_FORMAT
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ttag-now
This should be enough for you to format your date any way, you wish.
- [Django]-How to process a form (via get or post) using class-based views?
- [Django]-How can I disable logging while running unit tests in Python Django?
- [Django]-Django: Get ImageField url in view