--- !ruby/object:RI::MethodDescription 
aliases: []

block_params: 
comment: 
- !ruby/struct:SM::Flow::P 
  body: Convert to a formatted string. See Time::DATE_FORMATS for predefined formats.
- !ruby/struct:SM::Flow::P 
  body: This method is aliased to <tt>to_s</tt>.
- !ruby/struct:SM::Flow::H 
  level: 3
  text: Examples
- !ruby/struct:SM::Flow::VERB 
  body: "  datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0)   # =&gt; Tue, 04 Dec 2007 00:00:00 +0000\n\n  datetime.to_formatted_s(:db)            # =&gt; &quot;2007-12-04 00:00:00&quot;\n  datetime.to_s(:db)                      # =&gt; &quot;2007-12-04 00:00:00&quot;\n  datetime.to_s(:number)                  # =&gt; &quot;20071204000000&quot;\n  datetime.to_formatted_s(:short)         # =&gt; &quot;04 Dec 00:00&quot;\n  datetime.to_formatted_s(:long)          # =&gt; &quot;December 04, 2007 00:00&quot;\n  datetime.to_formatted_s(:long_ordinal)  # =&gt; &quot;December 4th, 2007 00:00&quot;\n  datetime.to_formatted_s(:rfc822)        # =&gt; &quot;Tue, 04 Dec 2007 00:00:00 +0000&quot;\n"
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Adding your own datetime formats to to_formatted_s
- !ruby/struct:SM::Flow::P 
  body: DateTime formats are shared with Time. You can add your own to the Time::DATE_FORMATS hash. Use the format name as the hash key and either a strftime string or Proc instance that takes a time or datetime argument as the value.
- !ruby/struct:SM::Flow::VERB 
  body: "  # config/initializers/time_formats.rb\n  Time::DATE_FORMATS[:month_and_year] = &quot;%B %Y&quot;\n  Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime(&quot;%B #{time.day.ordinalize}&quot;) }\n"
full_name: ActiveSupport::CoreExtensions::DateTime::Conversions#to_formatted_s
is_singleton: false
name: to_formatted_s
params: (format = :default)
visibility: public
