Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Time.rfc822

rfc822(date)

Alias of .rfc2822

Parses date as date-time defined by RFC 2822 and converts it to a Time object. The format is identical to the date format defined by RFC 822 and updated by RFC 1123.

ArgumentError is raised if date is not compliant with RFC 2822 or if the Time class cannot represent specified date.

See rfc2822 for more information on this format.

Example
require 'time'

Time.rfc2822("Wed, 05 Oct 2011 22:26:12 -0400")
#=> 2010-10-05 22:26:12 -0400

You must require ‘time’ to use this method.

See also .rfc2822 #rfc822 .strptime .parse also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0