class

Date

v3.2.13 - Show latest stable - Superclass: Object

No documentation available for this class.

Constants

DATE_FORMATS = {\n:short => "%e %b",\n:long => "%B %e, %Y",\n:db => "%Y-%m-%d",\n:number => "%Y%m%d",\n:long_ordinal => lambda { |date| date.strftime("%B #{ActiveSupport::Inflector.ordinalize(date.day)}, %Y") }, # => "April 25th, 2007"\n:rfc822 => "%e %b %Y"\n}

DAYS_INTO_WEEK = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6 }

Files

  • activesupport/lib/active_support/core_ext/date/acts_like.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/freeze.rb
  • activesupport/lib/active_support/core_ext/date/zones.rb
  • activesupport/lib/active_support/json/encoding.rb

1Note

simple use

Milind ยท Aug 5, 2014

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