在php.ini文件中设置PHP的时区 [英] Setting the Timezone for PHP in the php.ini file
问题描述
我正在尝试通过访问/etc/php5/cli/php.ini
文件并更改
I'm trying to change the default PHP timezone to Asia/Calcutta
by accessing the /etc/php5/cli/php.ini
file and changing
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
到
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Asia/Calcutta"
但是,当我尝试在phpinfo()
下查看当前时区时,时区紧随Europe/Berlin
时区.
However, when I try to view current timezone under phpinfo()
, the timezone follows the Europe/Berlin
timezone.
我尝试停止并重新启动Apache服务器,但是似乎并没有更改设置.
I have tried stopping and restarting the Apache server, but that didn't seem to have changed the settings.
在此过程中我缺少什么吗?
Is there something I'm missing in the process?
PS:我正在XAMPP下使用PHP 5.6.8.
PS: I'm using PHP 5.6.8 currently under XAMPP.
推荐答案
我尝试了发布的所有其他可能的解决方案,但是没有一个有帮助.这就是帮助我保存时区设置的原因:
I tried all the other possible solutions posted, but none of them helped. This is what helped me save my timezone settings:
1)转到phpinfo()
页并搜索Loaded Configuration File
,然后打开该部分下面提到的php.ini
文件.
1) Go to your phpinfo()
page and search for Loaded Configuration File
and open the php.ini
file mentioned under that section.
2)通过修改以下行来添加新时区,以更改默认时区设置:date.timezone=Asia/Kolkata
.
2) Change the default timezone settings by adding your new timezone by modifying this line: date.timezone=Asia/Kolkata
.
3)保存php.ini
文件并停止Apache服务器.
3) Save the php.ini
file and stop the Apache server.
4)重新启动Apache服务器.现在应该修改时区设置.
4) Restart the Apache server. The timezone settings should now be modified.
这篇关于在php.ini文件中设置PHP的时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!