php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50534 strtotime does not return false with wrong input
Submitted: 2009-12-19 23:51 UTC Modified: 2009-12-20 00:00 UTC
From: scripting at frag-em dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.2.12 OS: CentOS 4.3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: scripting at frag-em dot com
New email:
PHP Version: OS:

 

 [2009-12-19 23:51 UTC] scripting at frag-em dot com
Description:
------------
strtotime parses some forms of characters (probably as long as there is a separation with dots) to timestamps.
If there's no real date, it fails to return false.

date_default_timezone_set has been properly set

Reproduce code:
---------------
date_default_timezone_set('Europe/Amsterdam');
$time = strtotime("T.B.A.");
var_dump($time);
$time = strtotime("T.BA.");
var_dump($time);
$time = strtotime("TB.A.");
var_dump($time);
$time = strtotime("TBA");
var_dump($time);

Expected result:
----------------
bool(false)
bool(false)
bool(false)
bool(false)

Actual result:
--------------
int(somenumberthatchanges)
int(somenumberthatchanges)
bool(false)
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-20 00:00 UTC] derick@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

This is already fixed for PHP 5.3.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 20 00:00:02 2025 UTC