Skip to content

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

instance method

Date#to_time

() -> ::Time
to_time → time

Returns a new Time object with the same value as self; if self is a Julian date, derives its Gregorian date for conversion to the Time object:

Example
Date.new(2001, 2, 3).to_time               # => 2001-02-03 00:00:00 -0600
Date.new(2001, 2, 3, Date::JULIAN).to_time # => 2001-02-16 00:00:00 -0600
See also #to_s #tuesday? #to_datetime #upto also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0