Omnipresent Omnipresent - 4 years ago 250
Ruby Question

How to change default timezone for Active Record in Rails?

In my

I came across the following comment

# Set 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)'

As you see from above, I've made
to EST time. However, still when records are created in the DB, it looks like
is being stored in UTC format.

In the above comment, they say

...and make Active Record auto-convert to this zone...

How can I do that, and where?

Also, I'll be deploying this on heroku as well and i'd like the setting to carry over

Answer Source

adding following to application.rb works

 config.time_zone = 'Eastern Time (US & Canada)'
 config.active_record.default_timezone = 'Eastern Time (US & Canada)'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download