class
Date
rails latest stable
- Superclass: Object
No documentation available for this class.
Included modules
- DateAndTime::Calculations
- DateAndTime::Zones
Constants
DATE_FORMATS = {\nshort: "%d %b",\nlong: "%B %d, %Y",\ndb: "%Y-%m-%d",\ninspect: "%Y-%m-%d",\nnumber: "%Y%m%d",\nlong_ordinal: lambda { |date|\nday_format = ActiveSupport::Inflector.ordinalize(date.day)\ndate.strftime("%B #{day_format}, %Y") # => "April 25th, 2007"\n},\nrfc822: "%d %b %Y",\niso8601: lambda { |date| date.iso8601 }\n}
Attributes
| [RW] | beginning_of_week_default |
Files
- activesupport/lib/active_support/core_ext/date/acts_like.rb
- activesupport/lib/active_support/core_ext/date/blank.rb
- activesupport/lib/active_support/core_ext/date/calculations.rb
- activesupport/lib/active_support/core_ext/date/conversions.rb
- activesupport/lib/active_support/core_ext/date/zones.rb
- activesupport/lib/active_support/core_ext/object/json.rb
1Note
simple use
Examples
<%= @user.created_at.to_date.to_formatted_s(:long_ordinal)%> => July 5th, 2014
==OR
<%[email protected]_at.strftime("%b %d,%Y") %> => Jul 05,2014
===quick ref:- :db # => 2008-12-25 14:35:05 :number # => 20081225143505 :time # => 14:35 :short # => 25 Dec 14:35 :long # => December 25, 2008 14:35 :long_ordinal # => December 25th, 2008 14:35 :rfc822 # => Thu, 25 Dec 2008 14:35:05 +0000