Written by Sean Behan on Sun Jun 17th 2012

If you use a consistent date format often in your Rails applciation, it is worth it to add the format to your application environment. You can do this by adding  it to the bottom of the config/environment.rb file.

Time::DATE_FORMATS[:my_custom_format] = "%A %B %d, %Y"
Now you can use it in your views like this
@post.created_at.to_s(:my_custom_format)
Which will output something like Monday May 5, 2009

Tagged with..
#date #formatting #Rails #ruby #time #Ruby on Rails

Just finishing up brewing up some fresh ground comments...