Last active
July 24, 2019 19:07
-
-
Save pansapiens/204861 to your computer and use it in GitHub Desktop.
Django template for RFC-822 time format used in RSS feeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Django template snippet that gives the current time, | |
as an "RFC-822 compliant" date-time suitable for RSS feeds. | |
--> | |
<pubDate>{{ now|date:"D, d M Y H:i:s O" }}</pubDate> |
Thanks!
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
thanks