What timezone is Heroku server using?

青春壹個敷衍的年華 提交于 2019-12-18 12:48:01

问题


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 example.

2015-11-30T09:16:45.874086+00:00


回答1:


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

You can manually set your app's timezone 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 timezone 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).




回答2:


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.



来源:https://stackoverflow.com/questions/33995194/what-timezone-is-heroku-server-using

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!