Bug #54851 [NEW]: DateTime::createFromFormat, $format=='D' or $format=='l' Always Returns Today.
| From: | phpbugs at nicholassloan dot com | Date: | Wed, 18 May 2011 22:51:32 +0000 |
| Subject: | Bug #54851 [NEW]: DateTime::createFromFormat, $format=='D' or $format=='l' Always Returns Today. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-160823@lists.php.net to get a copy of this message | ||
From:
Operating system: Mac OS X
PHP version: trunk-SVN-2011-05-18 (SVN)
Package: Date/time related
Bug Type: Bug
Bug description:DateTime::createFromFormat, $format=='D' or $format=='l' Always
Returns Today.
Description:
------------
If the format only includes a day string ('D' or 'l'), it is ignored, and a
DateTime instance for the current date/time is returned. Maybe I'm a stupid
idiot,
but I would expect either an error, or for it to return a DateTime object
for the
next occurrence of the given day (similar to
\DateTime::__construct('Monday');)
Test script:
---------------
<?php
$date = new \DateTime('tomorrow');
$date2 = \DateTime::createFromFormat('D', $date->format('D'));
var_dump($date);
var_dump($date->format('D'));
var_dump($date2);
var_dump($date2->format('D'));
Expected result:
----------------
I expect the same date/day to be selected in both cases.
Actual result:
--------------
object(DateTime)#1 (3) {
["date"]=>
string(19) "2011-05-19 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "America/New_York"
}
string(3) "Thu"
object(DateTime)#2 (3) {
["date"]=>
string(19) "2011-05-18 18:49:33"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "America/New_York"
}
string(3) "Wed"
--
Edit bug report at http://bugs.php.net/bug.php?id=54851&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54851&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54851&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54851&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54851&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54851&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54851&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54851&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54851&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54851&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54851&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54851&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54851&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54851&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54851&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54851&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54851&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54851&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54851&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54851&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54851&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54851&r=mysqlcfg