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

Date.rfc3339

Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) → date

Creates a new Date object by parsing from a string according to some typical RFC 3339 formats.

Example
Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>

Raise an ArgumentError when the string length is longer than limit. You can stop this check by passing ‘limit: nil`, but note that it may take a long time to parse.

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