[英]date_default_timezone_get is sometimes slow to load
I am not sure why we added in the below to set the timezone but maybe 1 out of every 100 calls to date_default_timezone_get can take 5+ milliseconds to load.我不确定为什么我们在下面添加来设置时区,但每 100 次调用 date_default_timezone_get 中可能有 1 次可能需要 5 多毫秒才能加载。 Does anyone have any information on why this would sometimes run slow?
有没有人知道为什么这有时会运行缓慢? Servers are running on Google Cloud CentOS Linux 7 with PHP Version 5.6.40 (Yes I know it needs updated)
服务器在 Google Cloud CentOS Linux 7 上运行,PHP 版本 5.6.40(是的,我知道它需要更新)
// LOAD TIME: 1.692ms
if (!date_default_timezone_get('date.timezone')) {
// NEVERHIT
date_default_timezone_set('America/Chicago');
// LOAD TIME: 6.794ms
}
The line线
if (!date_default_timezone_get('date.timezone')) {
generates the warning生成警告
Warning: date_default_timezone_get() expects exactly 0 parameters, 1 given in..
警告:date_default_timezone_get() 需要 0 个参数,1 个在..
That takes a lot of time.这需要很多时间。 An if condition that is always true also makes no sense.
始终为真的 if 条件也没有任何意义。 The instruction
该指令
date_default_timezone_set('America/Chicago');
only takes a fraction of the time from instruction that generats warnings.从产生警告的指令中只需要一小部分时间。 The date_default_timezone_set() command should always be executed if there are uncertainties about the time zone of the environment.
如果环境时区不确定,则应始终执行 date_default_timezone_set() 命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.