Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Time.httpdate

(::String date) -> ::Time
httpdate(date)

Parses date as an HTTP-date defined by RFC 2616 and converts it to a Time object.

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

See httpdate for more information on this format.

Example
require 'time'

Time.httpdate("Thu, 06 Oct 2011 02:26:12 GMT")
#=> 2011-10-06 02:26:12 UTC

You must require ‘time’ to use this method.

See also #httpdate .gm .iso8601 .at also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0