php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19166 strtotime example in docs incorrect
Submitted: 2002-08-29 03:46 UTC Modified: 2003-10-28 16:27 UTC
From: jc at mega-bucks dot co dot jp Assigned: derick (profile)
Status: Not a bug 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:46 UTC] jc at mega-bucks dot co dot jp
The docs for strtotime contain a code snippet that is supposed to catch invalid dates. It fails in this example where $str is set to "1970-1-222" and invalid date.

$str = "1970-1-222";
if (($timestamp = strtotime($str)) === -1) {
  echo "The string ($str) is bogus";
}
else {
  echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
}

The output is:

1970-1-222 == Monday 10th of August 1970 12:00:00 AM

Whereas is should say that 1970-1-222 is a bogus date.

Jc

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-29 08:36 UTC] derick@php.net
Ok, I changed my mind and think this would be solved by fixing the function instead.
Because there is a Bug #18101 in which sniper promised that I would rewrite it, I'm marking this one as duplicate of that bug 18101.
 [2002-08-29 08:50 UTC] jc at mega-bucks dot co dot jp
Your an angel. A quick call to checkdate() to verify the input might be all that's needed?
 [2003-10-28 16:27 UTC] sniper@php.net
One report per bug is enough..

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 11:01:31 2025 UTC