Edit report at https://bugs.php.net/bug.php?id=46597&edit=1
ID: 46597
Comment by: tom at kera dot name
Reported by: fsb at thefsb dot org
Summary: Inconsistent return values for
strtotime('0000-00-00')
Status: Bogus
Type: Bug
Package: Date/time related
Operating System: *
PHP Version: 5.*, 6CVS (2009-04-30)
Block user comment: N
Private report: N
New Comment:
@aharvey: There was no year 0. 1BC was followed by 1AD, and YYYY-MM-DD date
format, to the best of my knowledge, assumes AD.
Previous Comments:
------------------------------------------------------------------------
[2010-03-31 16:34:43] fsb at thefsb dot org
Thank you for the explanation.
------------------------------------------------------------------------
[2010-03-31 16:17:13] [email protected]
Sure, but strtotime() has long handled invalid month and day values the same
way as mktime() by effectively "rounding" them into valid values: the 0th day
of the month becomes the last day of the previous month, the 0th month is the
last month of the previous year, and so on. Given that interpretation,
0000-00-00 fairly obviously becomes the last day of November in the year -1
(better known as 2 BCE).
There's no chance that behaviour is going to be changed now: checkdate() is a
much better way of sniffing out invalid dates anyway, and it would be a
potentially nasty backward compatibility break for people relying on this
behaviour in strtotime().
------------------------------------------------------------------------
[2010-03-31 15:21:06] fsb at thefsb dot org
[email protected]: Any date with month=zero or day=zero is invalid, regardless of
the year value. '0000-00-00' is not a date and has no corresponding unix
timestamp.
------------------------------------------------------------------------
[2010-03-31 05:17:47] [email protected]
This isn't a bug. The year 0 is well within the range of a 64-bit UNIX
timestamp, strtotime's semantics for invalid values (such as
defining the month and day as 0) are well established at this point,
and I see little value in special casing 0000-00-00 and plenty of
possible WTFs down the line if it's done.
------------------------------------------------------------------------
[2010-03-30 22:09:56] contractfrombelow at gmail dot com
We are getting this same problem, but only on 64 bit platforms. I've tested on
a
few different machines, all 64 bit machines return int(-62169955200). 32 bit
machines return bool(false) as expected. This happens on 5.2.x and 5.3.x.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=46597
--
Edit this bug report at https://bugs.php.net/bug.php?id=46597&edit=1