Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Adding extra data / time formats to your Rails application

By Peter Cooper / August 11, 2006

ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
  :default => "%m/%d/%Y",
  :date_time12 => "%m/%d/%Y %I:%M%p",
  :date_time24 => "%m/%d/%Y %H:%M"
)

Richard Leonard demonstrates how to use the date formats that come with Rails, as well as how to override or add some of your own directly into Rails' helpers on the fly.

Other Posts to Enjoy

Twitter Mentions