Skip to content

Instantly share code, notes, and snippets.

@selvan
Created July 20, 2012 04:12
Show Gist options
  • Save selvan/3148639 to your computer and use it in GitHub Desktop.
Save selvan/3148639 to your computer and use it in GitHub Desktop.
Timezone & Rails
How to configure timezone in Rails
====================================
Database table didn't care about timezone's. It just preserves datetime data.
Hence it is up to (Rails) applications to manage timezone's.
Rails application needs to manage timezone in two ways via configuration - config/application.rb
(See http://guides.rubyonrails.org/configuring.html for more details),
1. While storing data in DB, which TZ to use
> Allows us to use only :local or :utc TZ's
> This option can be configured with "config.active_record.default_timezone"
2. While displaying data to user which TZ to use
> Allows us to use many timezone's ( http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html)
> This option can be configured with "config.time_zone"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment