Set Rails Timezone

Posted By Weston Ganger

Working with time is something you will come across in your application. Its important to set the appropriate time zone in your config.

To see all the available time zones run this command: rake time:zones:all

# config/application.rb
...
module MyApp
  class Application < Rails::Application
    ...
    # This needs to be changed and is likely the only one you want to change
    config.time_zone = 'Pacific Time (US & Canada)'

    # This sets the time zone that ActiveRecord actually stores in the database
    # BE CAREFUL you usually always want to store in :utc which is default
    config.active_record.default_timezone = :local
    ...
  end
end

Related External Links:

Article Topic:Software Development - Ruby / Rails

Date:September 13, 2016