Doc #54139 [Opn]: All date acceptance functions should cross-reference checkdate()
| From: | ryan_a_martin at yahoo dot com | Date: | Wed, 02 Mar 2011 14:56:41 +0000 |
| Subject: | Doc #54139 [Opn]: All date acceptance functions should cross-reference checkdate() | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-6043@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54139&edit=1
ID: 54139
User updated by: ryan_a_martin at yahoo dot com
Reported by: ryan_a_martin at yahoo dot com
Summary: All date acceptance functions should cross-reference
checkdate()
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: N/A
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Test script was invalid:
----------
<?php
print_r(date_parse('2009-02-30'));
echo strtotime('2010-11-31');
?>
Previous Comments:
------------------------------------------------------------------------
[2011-03-02 15:54:58] ryan_a_martin at yahoo dot com
Description:
------------
Since PHP functions like strtotime, mktime, and date_parse do not catch
well-formatted but invalid dates like 2009-02-30 and 2010-11-31, it is
necessary to use checkdate() to catch them. All documentation pages that
document functions intended for accepting Gregorian dates should list
checkdate() in their "See Also" sections.
Test script:
---------------
print_r(date_parse('2009-02-30'));
print_r(strtotime('2010-11-31'));
Expected result:
----------------
For date_parse, error_count > 0 and an error thrown. For strtotime, an
error thrown, not a UNIX timestamp. Since this does not happen, we need
the documentation to make clear that these functions do not validate
Gregorian dates, and that a call to checkdate() is required to catch
such dates.
Actual result:
--------------
Array ( [year] => 2009 [month] => 2 [day] => 30 [hour] => [minute] =>
[second] => [fraction] => [warning_count] => 0 [warnings] => Array ( )
[error_count] => 0 [errors] => Array ( ) [is_localtime] => ) 1291179600
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54139&edit=1