Bug #66104 [Opn]: strtotime reports "2011-02-31" and "2011-11-31" as valid dates

From: Date: Tue, 13 Feb 2018 17:33:59 +0000
Subject: Bug #66104 [Opn]: strtotime reports "2011-02-31" and "2011-11-31" as valid dates
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213937@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66104&edit=1

 ID:                 66104
 Updated by:         cmb@php.net
 Reported by:        papaulsh at gmail dot com
 Summary:            strtotime reports "2011-02-31" and "2011-11-31" as
                     valid dates
 Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   WAMP
 PHP Version:        master-Git-2013-11-15 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

This looks more like a documentation problem.  Actually,
strtotime() is very liberal in what it takes.  2011-02-31 is
simply treated as 2011-03-03.  Use checkdate() to check whether
a given date is valid.


Previous Comments:
------------------------------------------------------------------------
[2015-09-30 14:54:12] boliveirasilva at gmail dot com

The same problem occurs for the following dates. (year doesn't matter)

'02/31/2014', '2016/02/31',
'02/30/2015', '2014/02/30',
'02/29/2015', '2015/02/29',

'31-02-2015', '2015-02-31', 
'30-02-2015', '2015-02-30',
'29-02-2015', '2015-02-29',

'11/31/2014', '2016/11/31', 
'31-11-2015', '2015-11-31'

------------------------------------------------------------------------
[2013-11-15 23:32:08] papaulsh at gmail dot com

Description:
------------
---
From manual page: http://www.php.net/function.strtotime#refsect1-function.strtotime-description
---
My summary info should be sufficient to define the problem, if further clarification is needed
please contact me.


Test script:
---------------
if  (!strtotime("2011-02-31")) {
     echo "<br />Invalid date";
}

Expected result:
----------------
Invalid date



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=66104&edit=1


Thread (1 message)

  • cmb@php.net
  • Unknown Message
    • cmb@php.net
« previous php.bugs (#213937) next »