php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61022 DateTime constructor ignores DateTimeZone argument in favor of string TZ
Submitted: 2012-02-09 02:30 UTC Modified: -
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: kavi at postpro dot net Assigned:
Status: Open Package: Date/time related
PHP Version: trunk-SVN-2012-02-09 (SVN) OS: n/a
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-02-09 02:30 UTC] kavi at postpro dot net
Description:
------------
When creating a new DateTime object, if given a parseable string with a timezone 
descriptor such as "Monday, 15-Aug-05 15:52:01 PDT" AND a DateTimeZone argument, 
the DateTimeZone argument will be completely ignored.

Please either reopen #40743 or fix this bug if it is a regression for a different 
reason.

This is broken on 5.3.3 and trunk.

Test script:
---------------
$a = new DateTime('Monday, 15-Aug-05 15:52:01 PDT', new DateTimeZone('America/New_York'));
print_r($a);


Expected result:
----------------
An exception.

If you absolutely must, which you shouldn't, a warning and an automatic conversion 
of the date string to the proper time in America/New_York.

Actual result:
--------------
DateTime Object
(
    [date] => 2005-08-15 15:52:01
    [timezone_type] => 2
    [timezone] => PDT
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 19:02:26 2014 UTC