Bug #53542 [Opn->Fbk]: DateTime raises a Warning when passed an incorrect date string
| From: | derick@php.net | Date: | Mon, 13 Dec 2010 23:31:42 +0000 |
| Subject: | Bug #53542 [Opn->Fbk]: DateTime raises a Warning when passed an incorrect date string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156979@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53542&edit=1
ID: 53542
Updated by: derick@php.net
Reported by: jeremycook0 at gmail dot com
Summary: DateTime raises a Warning when passed an incorrect
date string
-Status: Open
+Status: Feedback
Type: Bug
-Package: Performance problem
+Package: Date/time related
Operating System: Windows 7
PHP Version: 5.3.4
Block user comment: N
Private report: N
New Comment:
I get the normal exception:
$ php
<?php
$data= new DateTime('foo');
?>
PHP Fatal error: Uncaught exception 'Exception' with message
'DateTime::__construct(): Failed to parse time string (foo) at position
0 (f): The timezone could not be found in the database' in -:2
Stack trace:
#0 -(2): DateTime->__construct('foo')
#1 {main}
thrown in - on line 2
Which warning are you getting?
Previous Comments:
------------------------------------------------------------------------
[2010-12-13 21:46:20] jeremycook0 at gmail dot com
Description:
------------
Since upgrading to PHP 5.3.4 I'm finding that DateTime::__construct()
emits an
error of level E_WARNING instead of an Exception when passed an invalid
date/time
string.
Test script:
---------------
$date = new DateTime('foo');
Expected result:
----------------
An Exception should be raised.
Actual result:
--------------
An error of level E_WARNING.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53542&edit=1