Turn off RoRs automatic timezone conversion for columns

November 1, 2008 by Michael

I couldn’t find this in the documents, but Geoff Buesing showed me the hooks to turn off Ruby On Rails’ automatic timezone conversions for some columns of a model or a complete model:

# Turn it off for just some columns
class Picture < ActiveRecord::Base
 def self.skip_time_zone_conversion_for_attributes
   [:created_at, :published_at]
# Turin it off for the whole model
class Picture < ActiveRecord::Base
 def self.time_zone_aware_attributes

Thanks a lot!


  1. ashik ali wrote:

    Hi ,
    Actually I am developing rails front end application to integrate back end application via database . Not standalone Rails applications development.

    Highly appreciation for the rails developer to get the timezone as default also very easy to configure timezone .

    But when we talk about integrated application as like me that is java and rails both application access the same database where the situation
    I don’t like time conversion according to different timezones .

    So really it is very useful for me to integrate rails with java..etc without timezone conflict .

    Posted on April 8, 2010 at 9:38 AM | Permalink
  2. matt wrote:

    I was looking for the answer to that question all day. It works great. Thanks a lot !

    Posted on September 18, 2010 at 9:05 PM | Permalink
  3. Derek wrote:

    Thank you. For a schedule of events for a physical business, time zone is not important. This helped us greatly. Much appreciated.

    Posted on February 24, 2012 at 5:00 PM | Permalink
  4. josh schramm wrote:

    Thank you for this. Been trying to figure out this issue all day and finally stumbled on this post.

    Posted on January 8, 2013 at 8:59 PM | Permalink
  5. Michael wrote:

    You’re welcome Josh! Does this still work in newer Rails versions? Nice!

    Posted on January 9, 2013 at 9:00 AM | Permalink
  6. Sarah wrote:

    Thanks! Saved my life. Well, not literally, but definitely helped 😉

    Posted on May 12, 2015 at 2:42 AM | Permalink
Post a Comment

Your email is never published nor shared. Required fields are marked *