Reputation: 13
I have a database table named "events" with a column named "date." Entries under that in the format of "Sunday, August 05, 2012". I show it using events.date. How would I convert that string to a date with integers (like 8/5/12), and show it that way?
Upvotes: 1
Views: 98
Reputation: 1428
Actually, for exact result, i.e. "8/5/12", you should try this:
Date.parse("Sunday, August 05, 2012").strftime("%1m/%1d/%y")
Upvotes: 3
Reputation: 18835
you would use rails i18n features for this: http://guides.rubyonrails.org/i18n.html#adding-date-time-formats
Upvotes: 1