timmyRS timmyRS - 1 year ago 80
PHP Question

php.ini 'date.timezone' doesn't have any effect

My Problem

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


which is
and not
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
    way to often

  • I want the time to be
    for PHP just by changing the configuration

  • I want it to be
    at all times, ignoring Summer-/Wintertime

What solved it

In the comments, Minesh Patel told me to check if there is something overwriting my option, so I searched through my php.ini for
and it turns out there was another
-entry that overwrote it.

Answer Source

That line is certainly the correct place to change the default timezone.

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

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

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

  4. Check phpinfo() for more info on what the current timezone is.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download