Flowdock
to_formatted_s(format = :default) public

Convert to a formatted string - see DATE_FORMATS for predefined formats. You can also add your own formats to the DATE_FORMATS constant and use them with this method.

This method is also aliased as to_s.

Examples:

  time = Time.now                     # => Thu Jan 18 06:10:17 CST 2007

  time.to_formatted_s(:time)          # => "06:10:17"
  time.to_s(:time)                    # => "06:10:17"

  time.to_formatted_s(:db)            # => "2007-01-18 06:10:17"
  time.to_formatted_s(:short)         # => "18 Jan 06:10"
  time.to_formatted_s(:long)          # => "January 18, 2007 06:10"
  time.to_formatted_s(:long_ordinal)  # => "January 18th, 2007 06:10"
  time.to_formatted_s(:rfc822)        # => "Thu, 18 Jan 2007 06:10:17 -0600"
Show source
Register or log in to add new notes.