|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-12-13 21:46 UTC] 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Feb 14 22:00:01 2026 UTC |
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?