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
I tried to introduce Bootstrap 4 to the Rails 6 app [for beginners]
[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
How to change the timezone on Ubuntu
[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
Tips for using the Spotify app on Ubuntu
Create an app by specifying the Rails version
I summarized the naming conventions for each Rails
[Docker for Windows] The Docker app suddenly stopped working ...
Unify the Rails app time zone to Japan time
Use pagy for pagination in your Rails app.
[Heroku] Associate AWS S3 with the deployed Rails app
[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]
Challenge the settings for developing with vue.js on Rails 6
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
Heroku app moving (rails)
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: I've summarized the model and database for a moment.
[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āˆ
[Rails] Create new files required for the application at once