instance method
to_datetime
Ruby on Rails 2.3.18
Since v2.2.3 Last seen in v2.3.18Available in: v2.2.3 v2.3.18
Signature
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 84
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 84
· View on GitHub
· Improve this page
· Find usages on GitHub