instance method
to_date
Ruby on Rails 3.2.22.5
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 49
def to_date
return nil if self.blank?
::Date.new(*::Date._parse(self, false).values_at(:year, :mon, :mday))
end
Defined in activesupport/lib/active_support/core_ext/string/conversions.rb line 49
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in String