php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41964 strtotime returns a timestamp for non-time string of pattern '(A|a) .+'
Submitted: 2007-07-11 15:35 UTC Modified: 2007-07-12 19:02 UTC
From: al dot vazquez at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.3 OS: Linux
Private report: No CVE-ID: None
 [2007-07-11 15:35 UTC] al dot vazquez at gmail dot com
Description:
------------
strtotime return the current timestamp for the values 'A Revolution in Development' and 'a nothing'. Expected return value is false. This seems to be tripped by the first character being the letter 'a' or 'A' followed by a space followed by more text.

Reproduce code:
---------------
echo strtotime('Ask the Experts');
echo strtotime('A ');
echo strtotime('A');
echo strtotime('a ');
echo strtotime('a');
echo strtotime('A Revolution in Development');
echo strtotime('a nothing');

Expected result:
----------------
false
false
false
false
false
false
false

Actual result:
--------------
false
false
false
false
false
current timestamp
current timestamp

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-11 16:22 UTC] derick@php.net
There is indeed a bug:

derick@kossu:~$ php -r 'var_dump(date_parse("A"));'
array(12) {
  ["year"]=>
  bool(false)
  ["month"]=>
  bool(false)
  ["day"]=>
  bool(false)
  ["hour"]=>
  bool(false)
  ["minute"]=>
  bool(false)
  ["second"]=>
  bool(false)
  ["fraction"]=>
  bool(false)
  ["warning_count"]=>
  int(0)
  ["warnings"]=>
  array(0) {
  }
  ["error_count"]=>
  int(1)
  ["errors"]=>
  array(1) {
    [0]=>
    string(12) "Empty string"
  }
  ["is_localtime"]=>
  bool(false)
}

It is not an empty string...

Derick
 [2007-07-12 19:02 UTC] derick@php.net
This bug has been fixed in CVS.

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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC