#42675 [Asn->Bgs]: strtotime returns valid dates for invalid entries

From: Date: Sat, 08 Dec 2007 15:35:12 +0000
Subject: #42675 [Asn->Bgs]: strtotime returns valid dates for invalid entries
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120476@lists.php.net to get a copy of this message
 ID:               42675
 Updated by:       derick@php.net
 Reported By:      amykhar at gmail dot com
-Status:           Assigned
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Mac OS X
 PHP Version:      5.2.4
 Assigned To:      derick
 New Comment:

This is a feature, and it just returns Ilia's (and mine) expected date
of:
Oct 15 1992



Previous Comments:
------------------------------------------------------------------------

[2007-10-07 05:13:40] jazzattcs at yahoo dot com

I'm having the same problem. strtotime("February 31, 2007 18:45:00
GMT")should return FALSE but it just gets converted to March 3. I'm
using PHP 5.2.1 running on Windows.

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

[2007-09-17 15:10:29] amykhar at gmail dot com

If it is expected behavior, why does it behave differently for numeric

dates?  03/345/2007 returns invalid, as I would expect it to.  It seems

counterintuitive to have a function that is widely used to process
user-
entered data doing anything other than validating that the date entered

is an actual date.

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

[2007-09-16 15:37:42] iliaa@php.net

That is expected behavior. Although I would assume rather just adding 1

month to the date it would add 1 month + remaining # of days.

My expected return value would be: October 15, 1992

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

[2007-09-14 21:51:04] amykhar at gmail dot com

Description:
------------
If I enter a date with a text month and an invalid day, it returns as
valid.

Example, September 45, 1992 returns as valid.  It THINKS the date is
October 5, 1992.

(The same is true for Sep 45, 1992).

What it seems to do is to get the year correctly, then take the last
digit of the day and then add 1 to the month.



Reproduce code:
---------------
    	$cdate = strtotime("September 45, 1992");
    	if(!$cdate){
    		echo(-1);
    		exit;
    	}
        else{
             echo (date("M d Y",$cdate);
        }

Expected result:
----------------
It echo -1.

Actual result:
--------------
It prints out October 5, 1992


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


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


Thread (5 messages)

« previous php.bugs (#120476) next »