Following best practice to not modify php.ini directly but to have separate files, I have the following file:
$ cat /etc/php/7.0/apache2/conf.d/99-timezone.ini
[Date]
date.timezone="America/Los_Angeles"
I can see that the ini file is being loaded as evidenced by this phpinfo screenshot. However in the date section only one of the two directives has updated to show America/Los_Angeles and one is UTC. I don't even know where UTC is coming from, as the system's time is not UTC:
$ timedatectl
Local time: Tue 2017-11-07 18:36:56 PST
Universal time: Wed 2017-11-08 02:36:56 UTC
Timezone: America/Los_Angeles (PST, -0800)
(snip)
I see the following outputs when I run each of these:
var_dump(ini_get('date.timezone')); //string(19) "America/Los_Angeles"
var_dump(date_default_timezone_get()); //string(3) "UTC"
var_dump(date('e')); //string(3) "UTC"
How do I get the first two to local time?
Looking at your second screenshot, the only way for that to happen (that I know of) is if date_default_timezone_set('UTC'); has been called at runtime. It alters the 'Default Timezone', causing it to differ from the date.timezone value in your .ini files.
So look for things like:
auto_prepend_file= in your .ini file. This directive causes a script to be automatically prepended before every PHP file that is processed. If this is in use and the PHP file that it loads sets the timezone, it could cause this.
Are you using a PHP framework? If so, search the framework's PHP files for date_default_timezone_set. As an example, WordPress forces the timezone to UTC.
If not using a framework, are you using any PHP libraries that may contain date_default_timezone_set. If so, that could be the trouble.
The fact that it's showing up like this in your phpinfo() output suggests it is an auto_prepend_file doing this, because I'm assuming that you're checking phpinfo with a file that only contains <?php phpinfo(); — no framework or library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With