How To Set Rails Timezone

Posted by Weston Ganger on September 13, 2016

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

Related External Links:

Posted in Rails and Tagged with time timezone rails 

Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts