Change the default timezone for the rails app

problem of the published application was able to get the local time in the development environment, but when it was published, it was UTC time.

What i did

Change default time zone to Japan time

(app name)/config/application.rb

config.time_zone = 'Asia/Tokyo'

As a result, although it is registered in UTC time on the database, it is displayed as the time in Tokyo in the app (I think you can confirm that it was UTC + 9:00).

As a method to get today's date Change from to

Remember this method as it is often registered in the database with UTC time by default and changed to the local date and time using

Recommended Posts

Change the default timezone for the rails app
[Rails] Cancel / change the default password validation of devise
[Android] Change the app name and app icon for each Flavor
[Rails] How to change the page title of the browser for each page
How to change app name in rails
Prepare the security check environment for Rails 6
[Rails] Change the label name of f.label
Change the save destination of the image to S3 in the Rails app. Part 2
Publish the app made with ruby on rails
Change the timezone of the https-portal container to JST
Create an app by specifying the Rails version
[Docker for Windows] The Docker app suddenly stopped working ...
Unify the Rails app time zone to Japan time
[Ruby on Rails] How to change the column name
[Rails] How to change the column name of the table
What should I use for the testing framework [Rails]
Credentials referenced by the AWS SDK for Java by default
Specify VS Code as the default editor for jshell
AWS Lambda timezone change
Default value for server.servlet.session.timeout
Master the [Rails] scope!
Launch the Rails app locally in production mode (API Server)
Change the injection target for each environment with Spring Boot 2
[Rails] I tried using the button_to method for the first time
[Rails] [bootstrap] I want to change the font size responsively
[Rails] When the layout change of devise is not reflected
Change the setting value for each environment with Digdag (RubyOnRails)
Beginner-friendly Android app publishing procedure, struggling for the first releaseāˆ