Bug #53431 [NEW]: strtotime/DateTime object return incorrect results for invalid date/times
From:
Operating system: ALL
PHP version: Irrelevant
Package: Date/time related
Bug Type: Bug
Bug description:strtotime/DateTime object return incorrect results for invalid date/times
Description:
------------
When given an invalid date/time both strtotime and the DateTime object
returns the
current day at midnight instead
Test script:
---------------
[adam@nighe]$ php -r
'$x=strtotime("2011-00-00");printf("%s\n",date("Y-m-d
H:i:s",$x));'
2010-11-30 00:00:00
[adam@nighe]$ php -r '$x=new DateTime("2011-00-00");var_dump($x);'
object(DateTime)#1 (3) {
["date"]=>
string(19) "2010-11-30 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "America/New_York"
}
Expected result:
----------------
returns current day at midnight
Actual result:
--------------
strtotime should return FALSE
DateTime should throw an Exception.
--
Edit bug report at http://bugs.php.net/bug.php?id=53431&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53431&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53431&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53431&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53431&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53431&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53431&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53431&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53431&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53431&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53431&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53431&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53431&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53431&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53431&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53431&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53431&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53431&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53431&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53431&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53431&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53431&r=mysqlcfg
Thread (3 messages)
- adam-phpbugs at adam dot gs