config.time_zone = 'Central Time (US & Canada)'
config.active_record.default_timezone = :local
Hope this helps others that discover that the default behavior of UTC is not what is desired. Official documentation on these configuration items can be found at http://guides.rubyonrails.org/configuring.html#rails-general-configuration and http://guides.rubyonrails.org/configuring.html#configuring-active-record.
Thursday, December 13, 2012
Pinning Rails 3.2 to a specific time zone
I've been wrestling with some issues of dates and times in Rails. Being that I'm still pretty new to Rails, I been soaking up knowledge about this platform and today was no different. ActiveRecord, by default, converts timestamps and dates to UTC and interacts with them that way. UTC is also the format that the values will be stored in the database. If this is not what you want, you can pin your Rails system to a specific time zone by setting the following two configuration options in config/application.rb:
Labels:
rails
Subscribe to:
Post Comments (Atom)
Dealer’s Choice Inc. (DCI), began in 1990 providing services and partnering with automobile dealerships to maintain customer loyalty and enhance profitability. DCI provides auto dealers with tools and products that enable them to stay in touch with their customer base while providing quality Finance and Insurance products to increase their profit marginService ContractsOur Dealer clients maintain their ongoing relationship with Dealer’s Choice, Inc. because at DCI we view each Dealer customer as if they are our own.
ReplyDelete