What timezone is Heroku server using?

2019-04-03 17: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 example.

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

1条回答
叼着烟拽天下
2楼-- · 2019-04-03 17:46

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

查看更多
登录 后发表回答