Date.parse() is not your friend.

I’ve started looking at Ruby 1.9 with multiruby, and one of the first things that I found in testing is that Date.parse assumes European dates (dd/mm/yyyy format) in v1.9. The solution is to use strptime() instead so you can specify a format.

Date.strptime("12/31/2009", "%m/%d/%Y")

Tags: , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">