user984621 user984621 - 2 years ago 235
MySQL Question

MySQL - setting default timezone for a Rails application

I am using this setup in


config.time_zone = 'Eastern Time (US & Canada)'
config.active_record.default_timezone = 'Eastern Time (US & Canada)'

But when I am deploying the application to the server, I am seeing these warning messages:

warning: :database_timezone option must be :utc or :local - defaulting to :local

How to fix this warning? Should I add another

Rails cannot use the timezone I set above?

Thank you.

Answer Source


config.time_zone sets the default time zone for the application and enables time zone awareness for Active Record.

config.active_record.default_timezone determines whether to use Time.local (if set to :local) or Time.utc (if set to :utc) when pulling dates and times from the database. The default is :local.

So based on this, if you want to override your default timezone to Eastern time, you'd want to do:

config.time_zone = 'Eastern Time (US & Canada)'
config.active_record.default_timezone = :local

Let me know if this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download