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

查看:113
本文介绍了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天全站免登陆