I've set in php.ini file the default timezone:
date.timezone = Europe/Rome
I've also restarted httpd
service after the edit (service httpd restart), but when I call date_default_timezone_get()
, it returns 'UTC' value.
Why this happens?
Also calling php_info()
shows the timezone set in php.ini
PS. Sorry for my English.
If your code (including any frameworks) really does not change the timezone at all and you're running under a PHP version from 5.1.x to 5.3.x, it's possible, that the TZ
environment variable is set somewhere in your system. Then your date.timezone
setting would be ignored.
See the PHP manual page of date.timezone
(emphasis mine):
The default timezone used by all date/time functions. Prior to PHP 5.4.0, this would only work if the TZ environment variable was not set. […]
To check whether or not the TZ
environment variable is set in your system, you could use
if (isset($_ENV['TZ'])) {
echo 'TZ=' . $_ENV['TZ'];
}
else {
echo 'TZ not set';
}
or put
phpinfo();
somewhere in your code and check the "PHP Variables" section at the very bottom of its output.
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