Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
867 views
in Technique[技术] by (71.8m points)

datetime - Cannot Set date.timezone In php.ini file

I'm using php5.5 and getting this error whenever I used the date function in PHP:

 Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/info.php on line 1

the loaded configuration file is here:

/etc/php5/apache2/php.ini 

so I changed the date.timezone setting into this:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Jakarta

; http://php.net/date.default-latitude
;date.default_latitude = 31.7667

; http://php.net/date.default-longitude
;date.default_longitude = 35.2333

; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333

; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333

Then I restart the server:

sudo /etc/init.d/apache2 restart

but still getting this error, I tried to check the .ini file in the Additional ini file location but none of it is overriding the date.timezone setting

I've checked the php.ini file permission, but still not working please guide me to solve this problem, thanks..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this:

date.timezone = "Asia/Jakarta"

Edit:

Let's locate the correct php.ini. Fire this within apache / nginx / whatever web server deamon your using (because the command line version may be different by the one used by it).

<?php
phpinfo();
?>

What's the .ini in the output? Still the same?

Edit2:

After the php.ini edit, just restart the webserver (apache or nginx) ...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...