I have my app time zone set to Pacific.
# application.rb:
config.time_zone = 'Pacific Time (US & Canada)'
My production server time is set to Pacific. But ActiveRecord sets the per-session postgres time zone to 'UTC':
[1] pry(main)> ActiveRecord::Base.connection.execute("show timezone").getvalue(0,0)
(0.2ms) show timezone
=> "UTC"
The docs say my only two options for config.active_record.default_timezone
are :utc
and :local
Using :local
is fine for production, but my development server is in a different time zone.
I know it's often recommended to leave all time zone settings to the default UTC, but my app uses postgres's time and date functions extensively for ETL jobs, complex data analysis queries, etc. I would rather have postgres be my "single source of truth" than rails/ruby, so I'm not interested in answers that tell me to do everything in UTC
Edit: I've confirmed that config.time_zone
is properly set:
[6] pry(main)> Rails.application.config.time_zone
=> "Pacific Time (US & Canada)"
and config.active_record.default_timezone
is set to :local
[9] pry(main)> Rails.application.config.active_record.default_timezone
=> :local
in the same pry session:
[10] pry(main)> ActiveRecord::Base.connection.execute("show timezone").getvalue(0,0)
(0.2ms) show timezone
=> "Asia/Bangkok"