Pages

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:
    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.

5 comments:

  1. 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
  2. As a project manager, I use Scrum in my projects. The Guide to Scrum Body of Knowledge by SCRUMstudy provided a complete reference for the Scrum project I am working with. It is a very good book and extremely readable. I really liked sections on risk and quality. The tools mentioned in the processes were very helpful. I highly recommend this book if you are planning to implement Scrum in your organization. You can go through the first chapter available on http://www.scrumstudy.com Agile Certification

    ReplyDelete
  3. Good astrologycal post,thank you for sharing with society.
    For sofa repair work contact thesofastore gives
    Best Sofa Repair Services in Austin Town

    ReplyDelete
  4. Great post, thanks

    abhiram astrology center. Best Astrologer In alberta

    ReplyDelete