Erlang Central

RFC1123 Dates and Times

Revision as of 16:43, 3 December 2006 by RJ (Talk | contribs)


You need to convert from an Erlang Date or Time tuple to RFC 1123 format Dates and Times.


The Erlang httpd_util module provides a solution:

1> CurrTime = erlang:universaltime().
2> httpd_util:rfc1123_date(CurrTime).
"Sat, 28 Aug 2004 08:15:38 GMT"

Most applications that use RFC 1123 or RFC 822 time formats require all output in GMT. However, Erlang does not provide support for RFC 822 formatted time, since it assumes all input times are GMT.

3> LocalTime = erlang:localtime().
4> httpd_util:rfc1123_date(LocalTime).
"Sat, 28 Aug 2004 01:19:37 GMT"

If you need to parse dates as input, you can use httpd_util:convert_request_date function:

5> DateString = "Wed, 28 Apr 2004 17:22:10 Z".
"Wed, 28 Apr 2004 17:22:10 Z"
6> httpd_util:convert_request_date(DateString).

RFC 1123 (and RFC 822) are used frequently as the basis for exchanging dates and times, particularly in Internet applications.

roulette tips fun casinos gambling online bingo strategy casinos bet online casino Casino Bonus online casino net online casino net free online casino tournament online slots