I'm trying to change default timezone in Rails 3.2.8 app to GMT+04:00, but I don't know how to do it. The following solutions do not work for me:
config.time_zone = 'Moscow'
config.time_zone = "(GMT+04:00) Moscow"
config.active_record.default_timezone = 'Moscow'
config.active_record.default_timezone = :local
Also I've tried in rails console the following:
ActiveSupport::TimeZone.all.map(&:name)
which returned a list of values, including "Moscow"
.
Time.zone
returned (GMT+00:00) UTC
which is not correct, it should be (GMT+04:00) UTC
. Then I changed Time.zone = "Moscow"
and Time.now
returned the correct value (... +0400).
So to fix it I simply used Time.now + 4.hour
, but I also need datetime_select to display my local time. Time.now + 4.hour
is not a correct solution.
How one can set default time zone to their local value?