In my php.ini I've set:
date.timezone = "Etc/UTC"
And the server's time is UTC+0 too, but when I try this script to get the timezone:
<?php print(date_default_timezone_get()); ?>
it returns
Europe/Berlin
which is UTC+2
and not UTC+0
and I don't see how it gets there.
Just to clearify:
- I have saved the the correct file at the correct path and restarted my server
- I do not want to modify my scripts, because I already used
date()
way to often - I want the time to be
UTC+0
for PHP just by changing the configuration - I want it to be
UTC+0
at all times, ignoring Summer-/Wintertime
I suggest you to refer this list in order to choose your timezone:
PHP timezones
Warning: Do not use any of the timezones listed in the following link, they only exist for backward compatible reasons, besides UTC:
PHP timezones only for backward compatible reasons
It is strongly recommended that you use the correct time zone for your location, such as Europe/Berlin:
In the comments, Minesh Patel told me to check if there is something overwriting my option, so I searched through my php.ini for
Europe/Berlin
and it turns out there was anotherdate.timezone
-entry that overwrote it.That line is certainly the correct place to change the default timezone.
Are you actually changing the right php.ini? Some setups can have multiple .ini files. Run
phpinfo();
and check Loaded Configuration File to see if it's that file.Check if there are no other definitions of that parameter in the file. It might override what you've set if you just copy-pasted it in wherever.
Check if the code does not override what you have set in the .ini file.
date_default_timezone_set()
sets it (and overrides) in PHP.Check
phpinfo()
for more info on what the current timezone is.Have you checked the "TZ" environment variable for your web server user? If it is set, the date.timezone php.init setting would not work as expected, like stated in the php manual:
Find "Europe/Berlin" in your php.ini file (get correct path to file with phpinfo();)
In some cases "date.timezone" parameters appears twice in file.
Be sure tu put correct timezones, from here (php timezones)