Private Island Networks Inc.

How do I format an RSS, RFC-822 pubDate using Python?

Apr 22, 2019 asked by anonymous
share
subscribe to mailing list:

Question / Issue:

How would I create a RFC-822 pubDate using Python? Here's an example of what I want to produce: Mon, 22 Apr 2019 04:00:00 PST
X-ray Engineering Services

Responses:

Date: April 22, 2019

Author: Mind Chasers

Comment:

There are various ways, but here's an example of what seems to work best for us: $ python3 ... >>> from datetime import datetime >>> import time >>> now = datetime.now() >>> print(now.strftime('%a, %d %b %Y %X ')+time.tzname[0]) Mon, 22 Apr 2019 15:19:28 EDT There's a %Z format fode for strftime, but it often returns an empty string. And sometimes we just hardcode the timezone for specific content if we know for sure it needs to be set to something and don't want the underlying OS and environment on a cloud server changing underneath us.

Post your answer or comment:

your email address will be kept private
authenticate with a 3rd party for enhanced features, such as image upload
previous month
next month
Su
Mo
Tu
Wd
Th
Fr
Sa
loading