Reputation: 48490
My application has been running for over 6 months in the UTC time zone. This means all ActiveRecord and MongoDB objects have been created in the UTC time zone. Curious enough, if I go ahead and change the applicable setting in application.rb:
config.time_zone = 'Eastern Time (US & Canada)'
Will this convert the records that were created in UTC to the EST time zone? What about the MongoDB records? (I use Mongoid as my Ruby driver). Is it as simple as flipping a switch in application.rb and that's it?
Upvotes: 1
Views: 327
Reputation: 434805
ActiveRecord will store everything in UTC regardless of what config.time_zone
says; I'm having a hard time finding an authoritative reference on this, the best I've found so far is the ActiveRecord::Timestamp
docs. MongoDB should also be storing everything in UTC:
Date
BSON Date is a 64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). The official BSON specification refers to the BSON Date type as the UTC datetime.
So nothing in your databases should change or need to be changed. The config.time_zone
setting is only used in the Rails side of things, it has nothing to do with what time zone is used inside your databases so you shouldn't have anything to worry about.
Upvotes: 3