Custom date formats in Rails
I like to keep my date formats all together, instead of having .strftime() mixed into my code.
Create a file /config/initializers/custom_date_formats.rb
Load your formats into Time::DATE_FORMATS
Time::DATE_FORMATS[:ymd] = "%Y-%m-%d"
Use like so:
@christmas_post.created_at.to_s(:ymd) # => "2009-12-25"

Posted by Wes in