Skip to content

Instantly share code, notes, and snippets.

@krasio
Created June 12, 2010 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krasio/435789 to your computer and use it in GitHub Desktop.
Save krasio/435789 to your computer and use it in GitHub Desktop.
# config/environment.rb
# setting default timezone for your app when firing up Rails
config.time_zone = 'UTC'
# app/controllers/application_controller.rb
# changing timezone to one selected by user if logged in
before_filter :set_time_zone
def set_time_zone
Time.zone = current_user.time_zone if logged_in?
end
# bunch of useful methods in http://apidock.com/rails/DateTime
# http://apidock.com/rails/DateTime/in_time_zone
# http://apidock.com/rails/DateTime/utc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment