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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 16:01:29 2024 UTC