php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45647 strtotime() returning 1999-11-30 for 00-00-00 00:00:00
Submitted: 2008-07-28 16:40 UTC Modified: 2008-07-28 19:17 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jon dot reed at jellyfish dot co dot uk Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.6 OS: Centos 5.1
Private report: No CVE-ID: None
 [2008-07-28 16:40 UTC] jon dot reed at jellyfish dot co dot uk
Description:
------------
As per bug #41523 which is reported fixed on Vista.

We're running a custom build RPM of 5.2.6
It looks like this bug has reappeared:

$incorrect = '1999-11-30';
$time = date('Y-m-d',strtotime('00-00-00 00:00:00')); 
$this->assertNotEqual($time, $incorrect);

This fails SimpleTest.

php -r "echo date('Y-m-d',strtotime('00-00-00 00:00:00'));"
1999-11-30

Reproduce code:
---------------
echo strtotime('00-00-00 00:00:00');

Expected result:
----------------
-1

Actual result:
--------------
943920000

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-28 19:17 UTC] derick@php.net
There is no bug here, 00-00-00 means 2000-00-00, which is 1999-12-00, which is 1999-11-30. No bug, perfectly normal.
 [2016-01-23 10:18 UTC] senz at senz dot su
@Derick, you are inconsistent with your opinion: https://bugs.php.net/bug.php?id=30190 and your logic is not obvious for end user, nor properly documented.
Also look at this comment http://php.net/manual/en/function.strtotime.php#101702 
IMHO year 0 should be considered as error, as in previous versions. Since this is BC issue. Alto this case is rare, but very misleading for inexperienced developer, when one's dev and production archs differs.
 [2016-01-27 18:33 UTC] me at navarr dot me
@senz  It is consistent.  Years '0000' and '00' are different, as '00' is the two year code for 2000.  The rest of the math checks out correctly.

Year '0000' does weird things in PHP now, though.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC