|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62704 3rd argument of DateTime::createFromFormat doesn't work
Submitted: 2012-07-31 11:35 UTC Modified: 2012-08-01 08:36 UTC
From: jachym dot tousek at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.4.5 OS: Windows 7 x64
Private report: No CVE-ID: None
 [2012-07-31 11:35 UTC] jachym dot tousek at gmail dot com
I thought these two commands are equal:
DateTime::createFromFormat('U', 1343730289, new DateTimeZone("Europe/Prague"))
DateTime::createFromFormat('U', 1343730289)->setTimeZone(new DateTimeZone("Europe/Prague"))

However they aren't. If that behaviour is correct (I'm unsure) can you explain why are they different?

Test script:
DateTime::createFromFormat('U', 1343730289)->setTimeZone(new DateTimeZone("Europe/Prague"))->getTimeZone()->getName() === DateTime::createFromFormat('U', 1343730289, new DateTimeZone("Europe/Prague"))->getTimeZone()->getName()

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-01 08:36 UTC]
For the first "command" please see the note on the DateTime::createFromFormat() 
manual page [1] which states:

  The timezone parameter and the current timezone are ignored
  when the time parameter either contains a UNIX timestamp
  (e.g. 946684800) or specifies a timezone 
  (e.g. 2010-01-28T15:00:00+02:00).

 [2012-08-01 08:36 UTC]
-Status: Open +Status: Not a bug
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 09:01:32 2024 UTC