php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35481 Timezone error date_default_timezone_get()
Submitted: 2005-11-29 22:49 UTC Modified: 2005-11-30 00:52 UTC
From: a dot schilder at gmx dot de Assigned: derick (profile)
Status: Not a bug Package: Date/time related
PHP Version: 5.1.1 OS: Windows XP Home
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: a dot schilder at gmx dot de
New email:
PHP Version: OS:

 

 [2005-11-29 22:49 UTC] a dot schilder at gmx dot de
Description:
------------
Using date_default_timezone_get() without having set a timezone before, produces an error:

"It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We selected 'Europe/Paris' for '1.0/no DST' instead".

I want to check the current timezone and this should be the correct function for it. I want to get a result to work with

Reproduce code:
---------------
<?php
echo date_default_timezone_get();
?>

Expected result:
----------------
Get an empty string, like with "ini_get('date.timezone')"). Also false or null would be okay.

Actual result:
--------------
Error message.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-29 22:56 UTC] sniper@php.net
Ever heard about @ ? 

 [2005-11-29 23:19 UTC] a dot schilder at gmx dot de
Of course, but IMHO this is the wrong behavior, because this function does not "rely on the system's timezone settings", it returns the current settings.
 [2005-11-29 23:28 UTC] sniper@php.net
Assigned to the author.
 [2005-11-30 00:52 UTC] nlopess@php.net
If you don't define the timezone settings, PHP will try to guess your timezone. Thats your case.
So, this function returns the timezone that is on use by the php functions, which can be the ini setting, the timezone define with date_default_timezone_set(), or the magical guess.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 11:01:31 2025 UTC