Cannot Set date.timezone In php.ini file

finally solved my problem, this is my Loaded Configuration File:

/etc/php5/apache2/php.ini 

modified the date.timezone here but it's not working.

So, I check the "Scan this dir for additional .ini files " values in phpinfo() which point to:

/etc/php5/apache2/conf.d 

then I search date.timezone from all files in that folder but found none.

this is my Additional .ini file parsed value in phpinfo():

/etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-json.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/20-xdebug.ini, /etc/php5/apache2/conf.d/30-mcrypt.ini 

I modified /etc/php5/apache2/conf.d/20-xdebug.ini, and appended this line:

date.timezone = Asia/Jakarta

very weird but this solved my problem !!!


Another solution for me after compiling PHP from source was to check php.ini was actually loading a config file. From command line

php --ini

returns

Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

Find it.

find -name "php.ini" #it was in /usr/local/php/php.ini
cp /usr/local/php/php.ini /usr/local/lib/php.ini

Restart php (in my case, /etc/init.d/php-fpm stop, /etc/init.d/php-fpm start) and it works fine. For some reason it got copied wrong.

  • Distro: Centos 7
  • Web Server: Nginx
  • Type: EC2 Instance

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


You should check out by locate php.in, if there somewhere has another one.

for me. there should have CLI for command line interface:

/etc/php5/cli/php.ini
/etc/php5/fpm/php.ini

change the /etc/php5/cli/php.ini

It works for me now.