Bug #61022 [Opn->Dup]: DateTime constructor ignores DateTimeZone argument in favor of string TZ
Edit report at https://bugs.php.net/bug.php?id=61022&edit=1
ID: 61022
Updated by: heiglandreas@php.net
Reported by: kavi at postpro dot net
Summary: DateTime constructor ignores DateTimeZone argument
in favor of string TZ
-Status: Open
+Status: Duplicate
Type: Bug
Package: Date/time related
Operating System: n/a
PHP Version: 7.1
Block user comment: N
Private report: N
New Comment:
We'Re tracking this now in https://bugs.php.net/bug.php?id=74274
Previous Comments:
------------------------------------------------------------------------
[2012-02-09 02:30:44] 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
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61022&edit=1
Thread (2 messages)