Heroku 服务器使用什么时区? [英] What timezone is Heroku server using?

查看:26
本文介绍了Heroku 服务器使用什么时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Heroku 的服务器使用哪个时区?我正在尝试使用 node-cron 并将时区排列起来,但我无法理解 Heroku 使用的时区.这是一个例子.

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

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

推荐答案

默认情况下,Heroku 将以 UTC 返回当前时间的调用.

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

您可以通过通过 config 命令添加 TZ 环境变量.请记住,您必须使用 tz 数据库时区格式.例如,如果您想将默认时区设置为美国中部时间,您可以使用以下命令(我假设您拥有/使用 heroku 工具带):

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"

正如 treecoder 在下面的评论中指出的那样;如果您愿意,可以通过 Heroku 仪表板添加 TZ ENV 变量.打开应用程序的仪表板并导航到设置"选项卡,然后在配置变量"下单击显示配置变量"按钮.然后您就可以添加 TZ = America/Chicago(或您需要的任何时区).

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

注意:TZ 环境变量不影响日志.请参阅第二个注释此处.

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

这篇关于Heroku 服务器使用什么时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆