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
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: 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

Pull Requests

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: Sat Sep 28 02:01:27 2024 UTC