instance method
to_datetime
Ruby on Rails 3.1.12
Since v3.0.20 Last seen in v3.2.22.5Signature
to_datetime()
Converts a Time instance to a Ruby DateTime instance, preserving UTC offset.
my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007 my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500 your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009 your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500
Source
# File activesupport/lib/active_support/core_ext/time/conversions.rb, line 82
def to_datetime
::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
end
Defined in activesupport/lib/active_support/core_ext/time/conversions.rb line 82
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Time