What timezone is Heroku server using?

后端 未结 4 1171
忘掉有多难
忘掉有多难 2020-12-09 07:40

What timezone does Heroku\'s servers use? I\'m trying to use node-cron and have the timezones line up, but I can\'t understand what timezone Heroku is using. Here\'s an exam

相关标签:
4条回答
  • 2020-12-09 08:22

    Heroku is UTC by default. You can change it by setting an env var to TZ=America/New_York or whatever, but I highly recommend you don't.

    It's really good practice to keep all your server stuff (Heroku, CMS, etc.) in sync at UTC, and to only change this when displaying times clientside with something like Luxon.

    Keeping this stuff in sync will save you a lot of headaches.

    0 讨论(0)
  • 2020-12-09 08:29

    According to this, Heroku Help Log, you can change it with TZ variable. However, this never changes your log times, as they are always UTC.

    0 讨论(0)
  • 2020-12-09 08:30

    Heroku is UTC by default. Open your app in heroku and go to app setting and click on Reveal Config Vars as in image

    and you have to add var as in image

    TZ=Asia/kolkata

    Then it will work fine for INDIA time zone. you can choose your time zone from time-zone-list.

    0 讨论(0)
  • 2020-12-09 08:34

    By default Heroku will return calls for current time in UTC.

    You can manually set your app's time zone by adding a TZ environment variable via the config command. Keep in mind that you must use the tz database time zone format. For example, if you wanted to set your default time zone to US Central time you would use the following command (I'm assuming you have/use heroku toolbelt) :

    heroku config:add TZ="America/Chicago"
    

    EDIT: As treecoder points out in the comment below; the TZ ENV variable can be added via the Heroku dashboard if you prefer. Open your app's dashboard and navigate to the 'settings' tab, then under 'config variables' click the 'reveal config vars' button. You will then be able to add TZ = America/Chicago (or whatever timezone you need).

    NOTE: The TZ environment variable does not affect logs. See the second note here.

    0 讨论(0)
提交回复
热议问题