Edit report at https://bugs.php.net/bug.php?id=62704&edit=1

 ID:                 62704
 Updated by:         sala...@php.net
 Reported by:        jachym dot tousek at gmail dot com
 Summary:            3rd argument of DateTime::createFromFormat doesn't
                     work
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Date/time related
 Operating System:   Windows 7 x64
 PHP Version:        5.4.5
 Block user comment: N
 Private report:     N

 New Comment:

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).

[1] http://php.net/manual/en/datetime.createfromformat.php


Previous Comments:
------------------------------------------------------------------------
[2012-07-31 11:35:59] jachym dot tousek at gmail dot com

Description:
------------
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:
---------------
var_export(
DateTime::createFromFormat('U', 1343730289)->setTimeZone(new 
DateTimeZone("Europe/Prague"))->getTimeZone()->getName() === 
DateTime::createFromFormat('U', 1343730289, new 
DateTimeZone("Europe/Prague"))->getTimeZone()->getName()
);

Expected result:
----------------
true

Actual result:
--------------
false


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62704&edit=1

Reply via email to