Skip to content

Instantly share code, notes, and snippets.

@ultraspeed
Created November 3, 2009 22:58
Show Gist options
  • Save ultraspeed/225550 to your computer and use it in GitHub Desktop.
Save ultraspeed/225550 to your computer and use it in GitHub Desktop.
# Changes the default date and time string formatters in Rails. See http://j.mp/2nZ022 and http://j.mp/1BRFSf for more info
#
# >> Time.now.to_s
# => "3rd Nov, 2009 10:54 PM GMT"
# >> Date.today.to_s
# => "3rd Nov, 2009"
Time::DATE_FORMATS[:default] = lambda { |time| time.strftime("#{time.day.ordinalize} %b, %Y %I:%M %p %Z") }
Date::DATE_FORMATS[:default] = lambda { |date| date.strftime("#{date.day.ordinalize} %b, %Y") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment