Edit report at https://bugs.php.net/bug.php?id=65787&edit=1

 ID:                 65787
 Comment by:         vascowhite at gmail dot com
 Reported by:        vascowhite at gmail dot com
 Summary:            DateTime::__construct() accepts all single letters
                     except 'j' as valid timezone
 Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   All?
 PHP Version:        5.5.4
 Block user comment: N
 Private report:     N

 New Comment:

I just found that this is a duplicate of bug #65747


Previous Comments:
------------------------------------------------------------------------
[2013-09-29 15:13:43] vascowhite at gmail dot com

Description:
------------
If just a single letter is passed to the constructor of \DateTime it is 
accepted 
as a valid timezone string. Except, for some strange reason, the letter 'j'.

Test script:
---------------
$date = new \DateTime('a');
var_dump($date);

Expected result:
----------------
I expect an exception to be raised with the message:-

Fatal error: Uncaught exception 'Exception' with message 
'DateTime::__construct(): 
Failed to parse time string (a) at position 0 (a): The timezone could not be 
found 
in the database' 

Actual result:
--------------
Except for when the letter 'j' is passed a DateTime object is created. For 
example 
the following code:-

$date = new \DateTime('a');
var_dump($date);

Will give the following output:-

object(DateTime)[1]
  public 'date' => string '2013-09-29 15:17:19' (length=19)
  public 'timezone_type' => int 2
  public 'timezone' => string 'A' (length=1)


Where it should raise an exception.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65787&edit=1

Reply via email to