Skip to content

Instantly share code, notes, and snippets.

@pansapiens
Last active July 24, 2019 19:07
Show Gist options
  • Save pansapiens/204861 to your computer and use it in GitHub Desktop.
Save pansapiens/204861 to your computer and use it in GitHub Desktop.
Django template for RFC-822 time format used in RSS feeds
<!--
Django template snippet that gives the current time,
as an "RFC-822 compliant" date-time suitable for RSS feeds.
Of course, you will probably never need to use this, since
generating RSS feeds via Django templates isn't the best way ...
you should use the Django feed syndication framework instead
( https://docs.djangoproject.com/en/dev/ref/contrib/syndication/ )
-->
<pubDate>{{ now|date:"D, d M Y H:i:s O" }}</pubDate>
@mcotton
Copy link

mcotton commented Apr 15, 2014

thanks

@dtarz
Copy link

dtarz commented Jun 21, 2019

Thanks!

@alexeiramone
Copy link

It only works if your're using the english default locale. If you're using another locale, please do this:

{% load i18n %} first and then
<pubDate>{% language 'en' %}{{ item.pubdate|date:"D, d M Y H:i:s O" }}{% endlanguage %}</pubDate>

Bonus:

<pubDate>{% language 'en' %}{{ item.pubdate|date:"r" }}{% endlanguage %}</pubDate> also works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment