Topic: Date formatting

Is there an easy way to take a datesamp like 2006-09-02, for example and turn it into something likw Saturday, September 2, 2006?

I'm looking at the ActionView date formatting helpers and I'm just not seeing anything similar.

Having the day of the week isn't vital, but it would be nice. smile


Re: Date formatting

You could use the function Date.strptime … ml#M001227

With it you can easily parse a date out of a string.
Then use strftime to put it in your favorite format.

My homepage:
Working at:
My blog: soaked and soaped

Re: Date formatting

Date (and Time) has a parse method in Rails which allows you to do this:

Date.parse('2006-09-02').strftime('%A, %B %d, %Y')
# => "Saturday, September 02, 2006"

Railscasts - Free Ruby on Rails Screencasts

Re: Date formatting

Thank you both! smile