How do I create a Ruby date object from this string "DD-MM-YYYY"?
+4
A:
You can use Time#parse.
Time.parse("20-08-2010")
# => Fri Aug 20 00:00:00 +0200 2010
However, because Ruby could parse the date as "MM-DD-YYYY", the best way is to go with DateTime#strptime where you can specify the input format.
Simone Carletti
2010-08-20 09:05:05