Forum: Ruby on Rails Default format for Date and update/create date on DB

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D48be99143e13e40d1c44a4da63a53f4?d=identicon&s=25 Mongeta 99 (raimon)
on 2009-03-02 12:38
Hello,


I've changed the default date format in my envornment.rb:

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(:default
=> '%d/%m/%Y')


Now I can display my database date rows with the .to_s and they appear
as expected: day,month,year.

But the dates in the database are wrong from the entered ones.

I've spent some time searching through the web/forums and all that I've
found are really difficult and hard solutions to solve this problem.

There's no automatic conversion from default format to database format ?

user format: dd/mm/yyyy
database format: yyyy-mm-dd

what I get in the database is yyyy-dd-mm

And my :db format is ok: :db=>"%Y-%m-%d"

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS
=> {:rfc822=>"%e %b %Y", :number=>"%Y%m%d", :short=>"%e %b",
:db=>"%Y-%m-%d", :long=>"%B %e, %Y",
:long_ordinal=>#<Proc:0x011a830c@/Users/montx/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/date/conversions.rb:11>}




thanks!

r.
This topic is locked and can not be replied to.