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: 2017-03-19 10:13 UTC
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: Duplicate Package: Date/time related
PHP Version: 7.1 OS: n/a
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kavi at postpro dot net
New email:
PHP Version: OS:

 

 [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

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-17 07:03 UTC] heiglandreas@php.net
-PHP Version: trunk-SVN-2012-02-09 (SVN) +PHP Version: 7.1
 [2017-03-19 10:13 UTC] heiglandreas@php.net
-Status: Open +Status: Duplicate
 [2017-03-19 10:13 UTC] heiglandreas@php.net
We'Re tracking this now in https://bugs.php.net/bug.php?id=74274
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC