php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52350 strtotime not handling invalid dates
Submitted: 2010-07-15 19:57 UTC Modified: 2010-07-16 05:47 UTC
From: ftdysa at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.2 OS: Linux 2.6.21.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 23 = ?
Subscribe to this entry?

 
 [2010-07-15 19:57 UTC] ftdysa at gmail dot com
Description:
------------
strtotime does not return false for the invalid date of February 30.


Test script:
---------------
echo strtotime('2010-02-30');
echo date('r', strtotime('2010-02-30'));

Expected result:
----------------
FALSE
Wed, 31 Dec 1969 19:00:00 -0500


Actual result:
--------------
1267506000
Tue, 02 Mar 2010 00:00:00 -0500


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-16 05:47 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-07-16 05:47 UTC] aharvey@php.net
This is intended behaviour: bar checkdate(), which is strict by design, PHP tries 
to be as liberal as possible about accepting dates and conforming invalid values 
to valid ones. This particular behaviour also mimics the long standing way the C 
(and PHP) mktime() works in terms of accepting days outside of the normal range 
for a month.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 27 02:01:29 2024 UTC