php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51464 date_default_timezone_get warnings
Submitted: 2010-04-02 18:49 UTC Modified: 2013-02-18 00:34 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: palmer_m at hotmail dot com Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.3.2 OS: Windows Vista
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: palmer_m at hotmail dot com
New email:
PHP Version: OS:

 

 [2010-04-02 18:49 UTC] 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:
---------------
$tz=@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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-02 19:31 UTC] derick@php.net
-Status: Open +Status: Feedback -Package: Compile Warning +Package: Date/time related
 [2010-04-02 19:31 UTC] derick@php.net
I can not reproduce this, the error is properly silenced for me:

derick@kossu:~$ pe 5.3.2
derick@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
derick@kossu:~$ php -n -derror_reporting=-1 -r '$tz=@date_default_timezone_get();'
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Nov 30 05:03:17 2021 UTC