For those who updated the DB with the save method, but the times in the created_at and updated_at columns do not match the current time.
ruby 2.4.10 Rails 5.2.4.3,
Rails time setting is Greenwich Mean Time You can change it to Japan Standard Time by setting the time zone from config / application.rb.
application.rb
module SampleApp
class Application < Rails::Application
config.time_zone = "Tokyo"
end
end
① Add time zone setting to application.rb ② Restart the rails console (3) Confirm that the time zone setting is applied by the time.current method.
① Add time zone setting to application.rb Open config / application.rb and add "config.time_zone =" Tokyo ""
application.rb
module SampleApp
class Application < Rails::Application
config.time_zone = "Tokyo"
end
end
② Start the rails console
$ rails console
(3) Confirm that the time zone setting is applied by the time.current method.
irb(main):003:0> Time.current => Wed, 17 Jun 2020 00:11:56 JST +09:00
Recommended Posts