Ok, feel a little stupid, if I put the date in the form yyyy-mm-dd and then
parse it I get the right result. Anyhow, this works as a resolution for me
but is still I think an important question if in the case I was receiving
dates in something like 'mm/dd/yyyy' how I can get it to parse right.


On Fri, Feb 4, 2011 at 11:32 AM, David Kahn <[email protected]>wrote:

> I am getting the month and day reversed in parsing a date. I am wondering
> if there is some intelligence in Ruby that knows that at the moment I am in
> Mexico, as the parsing is working as if I was
>
> "6/15/2008".to_date
> => ArgumentError: invalid date
>
> "15/6/2008".to_date
>  => Sun, 15 Jun 2008
>
> What I really want is my date to be understood as month/day/year. Is there
> a way to tell Ruby or Rails to do this? Been poking around on google and do
> not see an answer that works here.
>
> I found a page with this example, which makes me think maybe there is
> something weird going on due to my geographic location:
>
> '06/15/2008'.to_date 
> <http://apidock.com/rails/ActiveSupport/CoreExtensions/String/Conversions/to_date>
>          # => Sun, 15 Jun 2008
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to