php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34661 checkdate() function returns false on valid date
Submitted: 2005-09-27 19:15 UTC Modified: 2005-09-27 19:25 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: na at index20 dot ru Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.4.0 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: na at index20 dot ru
New email:
PHP Version: OS:

 

 [2005-09-27 19:15 UTC] na at index20 dot ru
Description:
------------
Checkdate fails if month eq 8 or 9 and passed directly to function. See reproduce code. 5.1 also affected.


Reproduce code:
---------------
echo "buggy:\n";
var_dump(checkdate(07, 01, 2005));
var_dump(checkdate(08, 01, 2005));
var_dump(checkdate(09, 01, 2005));
var_dump(checkdate(10, 01, 2005));

$m07 = '07';
$m08 = '08';
$m09 = '09';
$m10 = '10';

echo "ok:\n";
var_dump(checkdate($m07, 01, 2005));
var_dump(checkdate($m08, 01, 2005));
var_dump(checkdate($m09, 01, 2005));
var_dump(checkdate($m10, 01, 2005));


Expected result:
----------------
buggy:
bool(true)
bool(true)
bool(true)
bool(true)
ok:
bool(true)
bool(true)
bool(true)
bool(true)


Actual result:
--------------
buggy:
bool(true)
bool(false)
bool(false)
bool(true)
ok:
bool(true)
bool(true)
bool(true)
bool(true)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-27 19:25 UTC] marcot@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Please read the manual. Numbers prefixed by zero are interpreted as if they were in octal notation by PHP, and they are not valid numbers in that context; therefore, they are converted to decimal zero, which does not indicate a valid month. If you try 

var_dump(checkdate(9, 1, 2005));

You'll see that it works just fine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 20:01:31 2024 UTC