Site Sponsors:
Passable 'RFC 2822' Localtime in Python 3 
Time ... you would think that it would be easy to express on a computer... What could be more natural than counting the number of seconds?

Yet after decades of computerization, we are still 'haggling over the proper way to express time!

Here is what we cobbled together while creating a client-side API for the new, R&D, AboutTime HTML Server:

import datetime
from email import utils

zdt = # Omits the GMT Offset
zlocal = utils.localtime(zdt) # Adds the official GMT Offset
localtime = utils.format_datetime(zlocal) # RFC 2822-ish

... and here is the output:

/usr/bin/python3.5 .../Python3/AboutTime_API/
2017-12-13 08:02:20.817119
2017-12-13 08:02:20.817119-05:00
Wed, 13 Dec 2017 08:02:20 -0500

Then, as one becomes interested in Zulu / Server Time:

zdt = datetime.datetime.utcnow() # Omits the GMT Offset
zulutime = utils.format_datetime(zdt) # RFC 2822-ish


2017-12-13 13:02:20.817251
Wed, 13 Dec 2017 13:02:20 -0000

For those who would like to use an enumerated set of timezones:
from datetime import timezone
znow =

We can also:
utc_date = znow.strftime(format='%Y-%m-%d %H:%M:%S [%z]')

Sharing is caring!


Google candy: GMT, UTC, Epoch time, conversion, email, RFC 822


Add Comment
Comments are not available for this entry.