【发布时间】:2010-04-08 19:50:47
【问题描述】:
我在 Fedora VM 上安装了 ZendServer CE (PHP 5.2),并且我将系统时区设置为“美国/芝加哥”。我的 php.ini 文件中有 date.timezone = 'UTC',当我调用 date_default_timezone_get() 或在网页上显示 date('T') 时,它会显示 'CDT'。
php.net 上 date_default_timezone_get() 的文档说它在选择默认时区时遵循此顺序:
- Reading the timezone set using the
date_default_timezone_set() function
(if any)
- Reading the TZ environment variable
(if non empty)
- Reading the value of the
date.timezone ini option (if set)
- Querying the host operating system
(if supported and allowed by the OS)
如果我通过“设置”GUI 更改系统时区并重新启动服务器,无论 php.ini 说什么,date('T') 都会返回我将系统时区更改为的内容。我也没有 TZ 环境变量,而且我目前没有在我的代码中的任何地方使用 date_default_timezone_set()。
知道会发生什么吗?我意识到我总是可以通过调用 date_default_timezone_set('UTC') 来覆盖系统时区,但如果可能的话,我宁愿依赖 php.ini 文件。
感谢您的帮助,
戴夫
【问题讨论】:
标签: php linux timezone utc zend-server-ce