php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19165 strtotime does not return -1 on some invalid dates
Submitted: 2002-08-29 03:43 UTC Modified: 2003-10-28 16:26 UTC
From: jc at mega-bucks dot co dot jp Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.2.2 OS: Red Hat Linux 7.2
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: jc at mega-bucks dot co dot jp
New email:
PHP Version: OS:

 

 [2002-08-29 03:43 UTC] jc at mega-bucks dot co dot jp
This code shows that strtotime does not recognize some dates that are in the correct format but invalid:

$bod = "1970-1-222";
echo "I think that $bod is timestamp " . strtotime($bod) . "<BR>";
echo "and that would be " . date("Y-n-d",strtotime($bod)). "<BR>";

The output is:

I think that 1970-1-222 is timestamp 19062000
and that would be 1970-8-10

The documentation says that strtotime should report -1 on a failure. Shouldn't this be a failure?

Jc

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-29 03:47 UTC] derick@php.net
I'm marking this as duplicate of 19166, because IMO this is a documentation problem rather than a problem in the code.

Derick
 [2002-08-29 03:51 UTC] jc at mega-bucks dot co dot jp
Ok. Does this mean that strtotime() is *not* meant to pick up invalid date inputs and fail on them?
 [2002-08-29 08:35 UTC] derick@php.net
Marking this as dup of 18101 instead, this beast needs rewriting :)

Derick
 [2003-10-28 16:26 UTC] sniper@php.net
Fixed in PHP 5, wont fix in PHP 4.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 13:01:27 2025 UTC