Todd Benson
5/10/2008 12:45:00 PM
On Sat, May 10, 2008 at 6:03 AM, John Butler <johnnybutler7@gmail.com> wrote:
> Is there a way to format a natural date like May 7, 2008 to 07/05/2008.
> Ive tried
> Date.strptime("May 7, 2008", '%d/%m/%Y') without success?
>
> Is it possible to this in a one line with ruby?
>
> JB
Yes, but I don't know why you would want to.
#strptime builds a Date object from your string with your format.
Then, you must format it.
If you don't need the Date object, I would just perform the magic on
the string itself. Matching month abbreviations to month numbers can
be done with Date::ABBR_MONTHNAMES.
hth,
Todd