There are four time zones to consider:
--Ruby process
--Affects Time.now
etc.
Time.zone.now
etc.NOW ()
etc. of SQL statementsAdded ʻENV TZ Asia / Tokyo to
Dockerfile` to support
Corresponding by setting TZ = Asia / Tokyo
in the environment variable
config.time_zone
config/application.rb
config.time_zone = 'Tokyo'
config.active_record.default_timezone
config/application.rb
config.active_record.default_timezone = :local
DB Connect to each DB of development environment and production environment and execute the following query
ALTER DATABASE db_name SET timezone TO 'Asia/Tokyo';
Since it is the writing method for Postgres, the writing method may differ depending on the type of DB.
It will be reflected when you reconnect to the DB.
Executing rails: db: migrate
will restore the timezone, but it's okay because you rarely write SQL statements in Rails in the first place.
There seems to be a way to set environment variables in docker-compose.yml, but it didn't work.
-Rails time zone summary-Qiita
Recommended Posts