instance method
to_date
Ruby on Rails 4.0.13
Since v3.0.20Signature
to_date()
Converts a string to a Date value.
"1-1-2012".to_date #=> Sun, 01 Jan 2012 "01/01/2012".to_date #=> Sun, 01 Jan 2012 "2012-12-13".to_date #=> Thu, 13 Dec 2012 "12/13/2012".to_date #=> ArgumentError: invalid date
Source
# File activesupport/lib/active_support/core_ext/string/conversions.rb, line 42
def to_date
::Date.parse(self, false) unless blank?
end
Defined in activesupport/lib/active_support/core_ext/string/conversions.rb line 42
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in String