php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54139 All date acceptance functions should cross-reference checkdate()
Submitted: 2011-03-02 15:54 UTC Modified: 2011-03-10 08:13 UTC
From: ryan_a_martin at yahoo dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2 OS: N/A
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ryan_a_martin at yahoo dot com
New email:
PHP Version: OS:

 

 [2011-03-02 15:54 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-02 15:56 UTC] ryan_a_martin at yahoo dot com
Test script was invalid:
----------
<?php

print_r(date_parse('2009-02-30'));

echo strtotime('2010-11-31');

?>
 [2011-03-02 15:58 UTC] derick@php.net
FYI, later versions of PHP 5.3 do add a warning:

derick@whisky:~$ php
<?php
print_r(date_parse('2009-02-30'));
?>
Array
(
    [year] => 2009
    [month] => 2
    [day] => 30
    [hour] => 
    [minute] => 
    [second] => 
    [fraction] => 
    [warning_count] => 1
    [warnings] => Array
        (
            [11] => The parsed date was invalid
        )

    [error_count] => 0
    [errors] => Array
        (
        )

    [is_localtime] => 
)
derick@whisky:~$ php -v
PHP 5.3.6-dev (cli) (built: Feb  2 2011 11:15:39) (DEBUG)
 [2011-03-02 16:27 UTC] ryan_a_martin at yahoo dot com
-PHP Version: Irrelevant +PHP Version: 5.2
 [2011-03-02 16:27 UTC] ryan_a_martin at yahoo dot com
That's good news, but our shop is still running PHP 5.2. Also, I'm not looking for a code change here, just some additional hyperlinks between related functions that are not currently present.
 [2011-03-10 08:13 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=309064
Log: Fix doc bug #54139 (All date acceptance functions should cross-reference
checkdate()) by cross referencing checkdate().
 [2011-03-10 08:13 UTC] aharvey@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: aharvey
 [2011-03-10 08:13 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 07:00:01 2026 UTC