php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53473 Allow system timezone on glibc-based systems
Submitted: 2010-12-04 21:07 UTC Modified: 2010-12-06 10:45 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: giecrilj at stegny dot 2a dot pl Assigned:
Status: Duplicate Package: Date/time related
PHP Version: 5.3.3 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: giecrilj at stegny dot 2a dot pl
New email:
PHP Version: OS:

 

 [2010-12-04 21:07 UTC] giecrilj at stegny dot 2a dot pl
Description:
------------
‘PHP Warning:  date(): It is not safe to rely on the system's timezone
settings.’

The warning is ridiculous.  It is not safe to drive a car, yet most people do
it every day.  And the remedy offered creates more problems that it solves
(AFAIK, it tries to solve the problem that the system administrator is
incompetent, which is not a problem of most system administrators, and it is
none of PHP’s business after all).

There are several workarounds for this warning, and none of them is good.

The workaround contained in the warning actually does more harm than good. 
There are numerous places where a configuration parameter can be set, including
live code.  The configuration files for various virtual servers can be
different.  If the time zone changes, e.g. when the application uses an
outsourced server, ALL these places must be updated.  There is no standard way
to specify sysconf change triggers, and even if there was one, the trouble of
doing is not justified by the advantage of specifying the time zone for PHP
separately (which is none).

The workaround of calling the date_default_timezone_set() function is more
appealing but it suffers the same disadvantages.  Because it must be done for
every single script that uses date, the only reasonable place to put it is in a
script preloaded to PHP.  However, there is no reasonable way to reliably
configure such a script system-wide, so it might work and it might also fail. 
Again, the advantage to implementing this tautology is NONE.

There is also a third workaround, not mentioned in the warning message, to set
the environment variable TZ:

TZ="$(date '+%Z')"

This is least pain but setting this environment variable is EXPLICITLY
DISCOURAGED by the documentation of GNU C library.

There is also no COMPILE-TIME SETTING to disable this warning.  Please provide
one and please turn it on when PHP is to be linked against glibc.  Thank you.

Test script:
---------------
<?php echo date('r'), "\n"; ?>

Expected result:
----------------
Sat, 04 Dec 2010 20:15:14 +0100

Actual result:
--------------
PHP Warning:  date(): It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting or the
date_default_timezone_set() function. In case you used any of those methods and
you are still getting this warning, you most likely misspelled the timezone
identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in Command
line code on line 1
Sat, 04 Dec 2010 20:15:14 +0100

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-06 10:45 UTC] aharvey@php.net
-Status: Open +Status: Duplicate
 [2010-12-06 10:45 UTC] aharvey@php.net
This is by design, per bug #39142.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 08:01:28 2024 UTC