date
Rails: Predefining date formats

To have a predefined set of date formats (e.g. to make a short version looking like 11/2009 and a long version displaying 01.11.2009 or 2009/11/01) you can define them in config/environment.rb, right after the final end notation:
Time::DATE_FORMATS[:short] = “%d.%m.%Y at %H:%M”Time::DATE_FORMATS[:news] = “%d.%m.%y”

Share this on:

Share this on:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • email
  • MisterWong
  • MySpace
  • Reddit
  • RSS
  • Yahoo! Bookmarks
Read More
Posted on 30th October 20092 Comments