Date environment.rb


#1

Hi Ruby-Comunity!

I have a problem with date format.

To display the german date format, I put on the end of environment.rb:

ActiveSupport::CoreExtensions::date::Conversions::DATE_FORMATS.merge!(:default
=> ‘%d.%m.%Y’)
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(:default
=> ‘%d.%m.%Y %H:%M:%S’)

In index/show.html.erb datetime is displayed like expected:

05.06.2009 10:00:00

In edit.html.erb datetime is not displayed in german date format:

<%= f.text_field :valid_from %> --> displays

2009-05-05 00:00:00

Have somebody a solution?

Thanks ahead!!

Regs

Hermann


#2

You can do this with i18n (Rails >= 2.2) setting up properly the
format in your config/locales (see examples in
http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) and
then use <%= l(some_date) %>.

Regards.

Franco C…

On May 17, 3:21 pm, Herman Müller removed_email_address@domain.invalid