Skip to content

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

class method

Date.rfc3339

(::String str, ?::Integer start) -> ::Date
Date.rfc3339(string = '-4712-01-01T00:00:00+00:00', start = Date::ITALY, limit: 128) → date

Returns a new Date object with values parsed from string, which should be a valid RFC 3339 format:

Example
d = Date.new(2001, 2, 3)
s = d.rfc3339   # => "2001-02-03T00:00:00+00:00"
Date.rfc3339(s) # => #<Date: 2001-02-03>

See:

Related: Date._rfc3339 (returns a hash).

See also #rfc3339 ._rfc3339 ._rfc822 .rfc2822 also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0