2

I've been having some problems with the configuration of timezone.

So I've seen some posts/questions about this topic and some say I should add the following configuration in the "application.rb".

config.time_zone = "Brasilia"

I've done that, but even after configuring this, if a run the following code in rails console I get (GMT+00:00) UTC

Time.zone

The same happens when a do

Time.now.in_time_zone

It responds in GMT 0.

Another problem that I think relates to this, is when choosing a datetime with the datetime_select tag. It seems as it's showing the right time but when the field is saved to the db is also on the UTC +00.

Raphael Melo
  • 365
  • 1
  • 3
  • 7
  • A question: are you trying to use different timezones dynamically? or are you trying to set up your I18n locale? – jaydel May 16 '11 at 13:23

1 Answers1

0

have you checked your {environments}.rb file (e.g. environments/development.rb)? The config values in application.rb are overridden by the same values in the environment .rb files. Perhaps you have GMT set in development.rb?

When I added config.time_zone = "Brasilia" to my development.rb file and ran rails c, I get:

ruby-1.9.2-p290 :001 > Time.zone
 => (GMT-03:00) Brasilia 
sorens
  • 4,975
  • 3
  • 29
  • 52