I need to parse a date string mentioned below to std date format.
Is there a built in function in ruby that would parse something like,
December 09, 2011 to 2011-12-09
I need to parse a date string mentioned below to std date format.
Is there a built in function in ruby that would parse something like,
December 09, 2011 to 2011-12-09
Do as below using
Date::parse
:Date.parse
is already mentioned.I prefer
Date.strptime
. This methods is a reverse strftime.Date.parse
is a (maybe good) guess, withDate.strptime
you can parse each date, when you know which format you expect.Example:
Or if you have another format where
Date.parse
fails: