|  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
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
 [2012-02-09 02:30 UTC] kavi at postpro dot net
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 

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'));

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-17 07:03 UTC]
-PHP Version: trunk-SVN-2012-02-09 (SVN) +PHP Version: 7.1
 [2017-03-19 10:13 UTC]
-Status: Open +Status: Duplicate
 [2017-03-19 10:13 UTC]
We'Re tracking this now in
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 06:05:45 2022 UTC