Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Time#rfc822

rfc822

Alias of #rfc2822

Returns a string which represents the time as date-time defined by RFC 2822:

day-of-week, DD month-name CCYY hh:mm:ss zone

where zone is [+-]hhmm.

If self is a UTC time, -0000 is used as zone.

Example
require 'time'

t = Time.now
t.rfc2822  # => "Wed, 05 Oct 2011 22:26:12 -0400"

You must require ‘time’ to use this method.

See also #rfc2822 .rfc822 #round #nsec also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0