Hi,

I'm having problem at the moment trying to parse a date. I'm reading in
2 dates from the view and want to search a DB for records between the 2
dates.

The 2 dates I read are in the format '%d.%m.%Y', e.g. 22.04.2009
The dates in the DB are stored as VARCHAR in the format '%Y/%m/%d
%H:%M:%S'

I've set the default date in environments.db as follows:
  ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
    :default => '%d.%m.%Y'
  )

I've tried parsing the 2 dates as follows:
Time.parse(params[:from]).strftime("%Y/%m/%d")

However the result is incorrect for my locale.
If I read in a date '12.04.2009' I would get the following output:
2009/12/04, when what I want is 2009/04/12. It's getting the day and
month mixed. The Locale on my machine is correct and the timezone in the
environments.db is set to UTC.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to