php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45285 DateTime() doesn't get zone from ini
Submitted: 2008-06-16 18:39 UTC Modified: 2008-06-24 01:00 UTC
From: davidn at virtuant dot com Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.2.6 OS: Win Vista, Win 2003Server
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-06-16 18:39 UTC] davidn at virtuant dot com
Description:
------------
My php.ini:

[Date]
; Defines the default timezone used by the date functions
date.timezone = "America/New_York"

When using the new DateTime() function: without explicitly setting the actual timezone in code, no timezone is recognized.

Also, when using date_default_timezone_set(), you can't depend on date_default_timezone_get() to get the .ini setting. It doesn't work.

Reproduce code:
---------------
date_default_timezone_set(date_default_timezone_get());

$datetime = new DateTime();
$datetime->format('G'), 0, 0);	// top of hour
echo $datetime->format(DATE_RFC3339);



Expected result:
----------------
2008-06-16T18:00:00+01:00 

Actual result:
--------------
2008-06-16T18:00:00+00:00 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-16 21:56 UTC] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

Your reproducible code is broken, please provide working code.
 [2008-06-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC