# Default format for Date and update/create date on DB

**URL:** <https://www.ruby-forum.com/t/default-format-for-date-and-update-create-date-on-db/161780>\
**Category:** Rails\
**Created:** [March 2, 2009, 12:38pm UTC](https://www.ruby-forum.com/t/default-format-for-date-and-update-create-date-on-db/161780 "2009-03-02T12:38:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [March 2, 2009, 12:38pm UTC](https://www.ruby-forum.com/t/default-format-for-date-and-update-create-date-on-db/161780/1 "2009-03-02T12:38:34Z")

</div>

Hello,

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

ActiveSupport::CoreExtensions:📅: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:📅: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.
