Bug->Doc #65747 [Opn]: DateTime __construct error
| From: | requinix@php.net | Date: | Sun, 29 Sep 2013 22:43:05 +0000 |
| Subject: | Bug->Doc #65747 [Opn]: DateTime __construct error | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10330@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65747&edit=1
ID: 65747
Updated by: requinix@php.net
Reported by: mwiseman at dogandtuba dot com
Summary: DateTime __construct error
Status: Open
-Type: Bug
+Type: Documentation Problem
Package: Date/time related
Operating System: Windows
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Expected but undocumented behavior.
Single characters correspond to military timezones. See
http://en.wikipedia.org/wiki/List_of_military_time_zones
foreach (range("a", "z") as $l) {
if ($l == "j") continue;
printf("%s = %s\n", $l, (new DateTime($l))->format("r"));
}
So the list of timezones documentation should be updated to mention these.
Previous Comments:
------------------------------------------------------------------------
[2013-09-29 15:56:59] vascowhite at gmail dot com
Related To: Bug #65787
------------------------------------------------------------------------
[2013-09-23 23:44:15] mwiseman at dogandtuba dot com
Description:
------------
Constructing a DateTime object with a string argument of 1 character creates a DateTime object set
to now, instead of throwing an exception.
If the string contains two characters (e.g. DateTime('aa')) an exception is thrown.
Test script:
---------------
<?php
date_default_timezone_set('America/Los_Angeles');
$d = new DateTime('x');
echo $d->format('y-m-d');
?>
Expected result:
----------------
Throw an exception
Actual result:
--------------
Valid DateTime object set to now.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65747&edit=1