php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #41842 Cannot create years < 0100 & negative years with date_create or new DateTime
Submitted: 2007-06-28 16:36 UTC Modified: 2007-07-12 19:01 UTC
From: mattsch at gmail dot com Assigned: derick
Status: Closed Package: Feature/Change Request
PHP Version: 5.2.3 OS: Gentoo Linux 2007.0
Private report: No CVE-ID:
 [2007-06-28 16:36 UTC] mattsch at gmail dot com
Description:
------------
When attempting to create a new date with a negative year and display that date, the format function returns today's date with the timezone offset modified and set to what the negative year should be.

Reproduce code:
---------------
<?
$date = new DateTime('-2007-06-28');
echo $date->format(DATE_ISO8601);
?>

Expected result:
----------------
Output:

-2007-06-28T11:31:19-0500

Actual result:
--------------
Outputs:

2007-06-28T11:31:19-2007

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-28 18:17 UTC] derick@php.net
The current code was not meant to do this, so it's not a real "bug" - however, I'll check whether we can support this without breaking something else.
 [2007-06-29 17:22 UTC] mattsch at gmail dot com
I have discovered that it is also unable to create years between 0000 and 0099.
 [2007-06-30 02:13 UTC] rasmus@php.net
Sure you can.  But of course a leading 0 indicates an octal number, so 099 is not a valid number.  
 [2007-06-30 16:58 UTC] mattsch at gmail dot com

 [2007-07-12 19:01 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 02:02:27 2014 UTC