What date formats does the HTTP protocol support?

Posted: (EET/GMT+2)

 

The latest HTTP protocol version 1.1 is the most common version currently in use, and the standard text in RFC 2068 clarifies many things in the original HTTP 1.0 specification. I was today looking into the standard text as I needed to investigate how date/time formats are handled.

The current version supports three separate date formats to remain compatible with HTTP/1.0. The RFC document uses these examples:

Sun, 06 Nov 1994 08:49:37 GMT

Sunday, 06-Nov-94 08:49:37 GMT

Sun Nov  6 08:49:37 1994

The first one is the one suggested for use (RFC 822), but the two later format (last is from the ANSI C language) are supported too. Note that the two first formats use a time zone indicator. This must always be "GMT" for Greenwich Mean Time.

From programming perspective, pick the first format and stick to it. If you are not using a framework to write the HTTP headers, create a function that converts a date/time value in your programming language to a correctly formatted string. Then, you can also test this date generation work independent of the HTTP logic.

Hope this helps!