php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53542 DateTime raises a Warning when passed an incorrect date string
Submitted: 2010-12-13 21:46 UTC Modified: 2010-12-14 16:40 UTC
From: jeremycook0 at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.4 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jeremycook0 at gmail dot com
New email:
PHP Version: OS:

 

 [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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-14 00:31 UTC] derick@php.net
-Status: Open +Status: Feedback -Package: Performance problem +Package: Date/time related
 [2010-12-14 00:31 UTC] derick@php.net
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?
 [2010-12-14 15:08 UTC] jeremycook0 at gmail dot com
-Status: Feedback +Status: Closed
 [2010-12-14 15:08 UTC] jeremycook0 at gmail dot com
Thanks for the reply Derick. I think this was a false alarm. I'm using the dbg 
debugging extension and it seems that having the option 'debugger.JIT_enabled=on' 
causes this problem. Once I changed this setting to off the problem didn't occur. 
I'll bring this up with NuSphere.

Sorry to waste your time,

Jeremy.
 [2010-12-14 16:40 UTC] cataphract@php.net
-Status: Closed +Status: Bogus
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Feb 14 22:00:01 2026 UTC