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.

3 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. Another way to future proof your career is to always keep acquiring new skills and get certified. PMP Certification is grt if you're at a project management level or aspire to be in http://www.pmstudy.com has a great free test if you'd like to gauge your project management knowledge.The PMP Certification

    ReplyDelete
  3. 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