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 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts