Time zone changing of a Heroku App🚀

·

2 min read

Time zone changing of a Heroku App🚀

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)

  1. Open the command shell.
  2. Log In to Heroku.
  3. Navigate to your app's directory.
  4. Now, set up your Time Zone variable as TZ
heroku config:add TZ="America/Los Angeles"

WAY-02 (From the Heroku dashboard)

  1. Login into the Heroku dashboard from a browser LOGIN.png

  2. Navigate to the app for changing the time zone. NAV.png

  3. Click over the Settings tab. 43.png

  4. Press the "Reveal Config Vars" button. 44.png

  5. Set the key to "TZ" and the value to your timezone (E.g.: America/Los Angeles). 45.png

  6. Press the Add button. 46.png

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!