Sunday, September 30, 2007

RFC 1123 Date Time Format

Using strftime format specifiers (used by every scripting language), the RFC 1123 time format is
%a, %d %b %Y %H:%M:%S GMT
(assuming you are using the "C" or a english local, and UTC time). In python this would be:
$ python
>>> import datetime
>>> datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
'Sun, 30 Sep 2007 14:58:05 GMT'
>>> 

Note, the "%a, " is optional.

Good luck looking that up directly. It's on page 55 of RFC 1123, which it's just a change to RFC 822 to be "year 2000 compliant" so you have go track down the original spec (it's in section 5). Which is in BNC format.

I should really make a master page listing standard time formats and their equivalent strftime format.

2 comments:

andy said...

Why on earth are you reading an RFC on a Sunday afternoon?

Why on earth am I reading this blog post on a Sunday afternoon?

rukeba said...

Thank you. Very useful.