由网友(最遠的距離是心與心的距離)分享简介:在我的 application.rb中我遇到了以下注释In my application.rb I came across the following comment# Set Time.zone default to the specified zone and make Active Record auto-c...
在我的 application.rb中
我遇到了以下注释
In my application.rb
I came across the following comment
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'Eastern Time (US & Canada)'
正如你从上面看到的,我做了 config.time_zone
来EST时间。不过,还是当记录在数据库中创建,它看起来像日期时间
被存储在UTC格式。
As you see from above, I've made config.time_zone
to EST time. However, still when records are created in the DB, it looks like datetime
is being stored in UTC format.
在上面的评论,他们说
......,使活动记录自动转换到该区域...
...and make Active Record auto-convert to this zone...
如何才能做到这一点,在哪里?
How can I do that, and where?
另外,我会在Heroku被部署此同时,我想设置结转
Also, I'll be deploying this on heroku as well and i'd like the setting to carry over
推荐答案
添加以下内容 application.rb中
和
config.time_zone = 'Eastern Time (US & Canada)'
config.active_record.default_timezone = 'Eastern Time (US & Canada)'
相关推荐
最新文章