Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Set date.timezone In php.ini file

Tags:

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..

like image 228
Edxz Avatar asked Dec 08 '13 09:12

Edxz


People also ask

Where is date timezone in PHP INI?

ini file is located at the /etc directory. Depending on the installed version of PHP version, you will find a [Date] section like the following. If it is not there, just add a line with the "date. timezone = Your/Timezone" function.

How can I modify the PHP timezone setting for my website?

Open Hosting → Manage → PHP Configuration page. There, open the PHP options tab and edit the date. timezone value: If you are not sure which time zone to insert, check the Time Zone Map.

What is UTC timezone PHP?

The default timezone for PHP is UTC regardless of your server's timezone. This is the timezone used by all PHP date/time functions in your scripts. To change the PHP timezone for an app, create a .user.ini file in the app's public directory with the following contents: date.timezone = America/Los_Angeles.


1 Answers

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) ...

like image 76
Damiano Barbati Avatar answered Oct 15 '22 14:10

Damiano Barbati