Issue
I want to change the timezone of my Heroku Postgres database.
Resolution
We highly suggest leaving your database times in UTC and modifying them at your application level. This results in your data being more ubiquitous and easier to convert when needed. Having dates in the database using a different timezone to be problematic since many libraries and functions often expect dates and times in UTC.
If you need to change the timezone, you can do so by connecting to your Heroku Postgres instance with $ heroku pg:psql
and running ALTER DATABASE your_database_name SET timezone = timezone_name
. However, please consider the repercussions of changing the timezone for your application.
For example: ALTER DATABASE your_database_name SET timezone = 'Brazil / East';
.
You can find the name of the different timezones recognized by PostgreSQL by running SELECT * FROM pg_timezone_names;
on your database.