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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ftdysa at gmail dot com
New email:
PHP Version: OS:

 

 [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: Wed Jun 19 19:01:32 2024 UTC