Recently, I was doing an automation tool project and have to deploy it with cron jobs on Heroku to run this tool at a specified time on a daily basis. The time zone that I needed to run this tool was America/Los Angeles. But the tool was running on the default UTC time zone of Heroku. So, to run this tool at a specified time from America/Los Angeles time zone I needed to change the time zone on Heroku.
Luckily Heroku let's us change the timezone of our app simply by adding a new config var named as TZ
. You can change it in 2 ways. The steps needed to change it are as follow:-
WAY-01 (From the Heroku CLI)
- Open the command shell.
- Log In to Heroku.
- Navigate to your app's directory.
- Now, set up your Time Zone variable as
TZ
heroku config:add TZ="America/Los Angeles"
WAY-02 (From the Heroku dashboard)
Login into the Heroku dashboard from a browser
Navigate to the app for changing the time zone.
Click over the Settings tab.
Press the "Reveal Config Vars" button.
Set the key to "TZ" and the value to your timezone (E.g.: America/Los Angeles).
Press the Add button.
How do I know which is the correct TZ
value?
Follow this link to see the complete list of time zones.
Thank you for reading! Do share your valuable feedback and suggestions!