Here's what PHP devs say about it (in the related discussion):
No - you, as an admin, are required to make an informed decision on
what you want your timezone to be. There have been way too many bug
reports where people had no clue, so now we throw a warning.
Derick Rethans is the author of this commit that turned date_warning from E_STRICT
(in PHP 5.2-) to E_WARNING
(PHP 5.3+).
The same discussion has quite a sound (yet obviously awkward) solution to this, applied by MediaWiki:
Actually, the sensible default is what guess_timezone()
does already,
except without the warnings. You can get that behaviour with e.g.
date_default_timezone_set( @date_default_timezone_get() );
at the top of your program. That's what MediaWiki does (except with by
modifying error_reporting
instead of using @
). We stole the idea from
another web app. It's more convenient than duplicating the
functionality of guess_timezone()
in the application.
It's Derick's prerogative to annoy all users half to death with
warnings, as his way of indicating his distaste for the state of OS
support for querying of system timezone. That's the reward we give him
for writing lots of date/time code.
The key part of this workaround is date_default_timezone_get
function, which, in order, returns the default timezone by...
- reading the timezone set using the
date_default_timezone_set()
function (if any)
- reading the TZ environment variable (if non empty) (Prior to
PHP 5.3.0
)
- reading the value of the
date.timezone
ini option (if set)
- querying the host operating system (if supported and allowed by the OS)