Skip to content

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

instance method

Date#to_datetime

d.to_datetime → datetime

Returns a DateTime whose value is the same as self:

Example
Date.new(2001, 2, 3).to_datetime # => #<DateTime: 2001-02-03T00:00:00+00:00>
See also #to_date #to_json #thursday? #to_s also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0