Edit report at http://bugs.php.net/bug.php?id=51464&edit=1

 ID:               51464
 Updated by:       [email protected]
 Reported by:      palmer_m at hotmail dot com
 Summary:          date_default_timezone_get warnings
-Status:           Open
+Status:           Feedback
 Type:             Bug
-Package:          Compile Warning
+Package:          Date/time related
 Operating System: Windows Vista
 PHP Version:      5.3.2

 New Comment:

I can not reproduce this, the error is properly silenced for me:



der...@kossu:~$ pe 5.3.2

der...@kossu:~$ php -n -derror_reporting=-1 -r
'$tz=date_default_timezone_get();'



Warning: date_default_timezone_get(): 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/London'
for 'BST/1.0/DST' instead in Command line code on line 1

der...@kossu:~$ php -n -derror_reporting=-1 -r
'$...@date_default_timezone_get();'


Previous Comments:
------------------------------------------------------------------------
[2010-04-02 18:49:33] palmer_m at hotmail dot com

Description:
------------
date_default_timezone_get() issues a notice even if you precede it with
an at-sign(@), whenever it was not set in the .ini file.  Consequently,
there is no way for the script to prevent the warning message.  It is
logical to check the existing timezone value before setting it using
date_default_timezone_set().  The current PHP rules make it impossible
to safely use the date functions when the timezone has not been
configured in the .ini file.  Also, you cannot tell from the
date_default_timezone_get() function whether or not you need to call
date_default_timezone_set() to prevent further warnings for subsequent
date() functions.  The reason you cannot tell is because
date_default_timezone_get() does not distinguish the source of its
returned value. 



Test script:
---------------
$...@date_default_timezone_get();

Expected result:
----------------
No visible warning issued to the web user.

Actual result:
--------------
PHP Warning: date_default_timezone_get(): 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 'America/Chicago'
for '-5.0/DST' instead


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51464&edit=1

Reply via email to