php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45977 strtotime returns time() with any string that begins with 'eat'
Submitted: 2008-09-02 22:57 UTC Modified: 2008-09-03 01:44 UTC
From: phocis at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.6 OS: BSD
Private report: No CVE-ID: None
 [2008-09-02 22:57 UTC] phocis at gmail dot com
Description:
------------
Strtotime returns time() with any string that begins with 'eat'

While this is related to: http://bugs.php.net/bug.php?id=43960

It is not exactly the same.

Reproduce code:
---------------
var_dump(strtotime('10 September 2000'));
var_dump(strtotime('10 September 2000 asdfasdfasdf'));
var_dump(strtotime('asdfasdfasdf 10 September 2000'));


var_dump(strtotime('eat'));
var_dump(strtotime('eat asdfasdfasdf'));
var_dump(strtotime('asdfasdfasdf eat'));

var_dump(strtotime('EAT'));

Expected result:
----------------
int(968569200) # 10 sept 200
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)


Actual result:
--------------
int(968569200) # 10 sept 200
bool(false)
bool(false)
int(1220360063) # time()
int(1220360063) # time()
bool(false)
int(1220360063) # time()


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-02 23:34 UTC] phocis at gmail dot com
So, I read the other bug report's comments a little more thoroughly and found out about "Double timezone specification"s.

What I really wanted was a is_perfect_time:

function is_perfect_time($time){
	$parsed = date_parse($time);
	return (
		$parsed['error_count'] === 0
		&& $parsed['warning_count'] === 0
	);
}

Sorry for the premature bug report.
-Carl
 [2008-09-03 01:44 UTC] scottmac@php.net
EAT is East Africa Time, hence its valid.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 27 02:01:29 2024 UTC