我有相当普遍的问题,但由于某种原因,我已经尝试了网上的所有建议,似乎没有任何工作.
我已将配置中的时区设置为'EST'
config.time_zone = 'Eastern Time (US & Canada)'
但是当屏幕上显示时间时,它会继续显示存储在数据库中的UTC时间.我尝试了调试器,这是输出
(rdb:1) Time.zone 
#<ActiveSupport::TimeZone:0x1061f4760 @utc_offset=nil, @current_period=nil, @name="Eastern Time (US & Canada)", @tzinfo=#<TZInfo::TimezoneProxy: America/New_York>>
(rdb:1) Order.first.placed_at
Fri Jan 01 15:00:00 UTC 2010
更新:这是另一个具有相同问题的用户 显示时Rails时区错误
我把它放在Application Controller中:
before_filter :set_timezone 
def set_timezone  
Time.zone = current_user.time_zone 
end  
但我总是得到错误:
undefined method time_zone for #<User:0xa46e358>
而我只是不知道为什么......
我希望有人能帮帮忙