Doc #61171 [Opn->Csd]: Ambiguous 'timezone' parameter description causes hair-pulling
| From: | krakjoe@php.net | Date: | Thu, 15 Nov 2012 09:38:57 +0000 |
| Subject: | Doc #61171 [Opn->Csd]: Ambiguous 'timezone' parameter description causes hair-pulling | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9139@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61171&edit=1
ID: 61171
Updated by: krakjoe@php.net
Reported by: chichilatte at gmail dot com
Summary: Ambiguous 'timezone' parameter description causes
hair-pulling
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Date/time related
PHP Version: Irrelevant
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2012-02-23 18:54:48] chichilatte at gmail dot com
Description:
------------
---
From manual page:
http://www.php.net/datetime.construct#refsect1datetime.construct-parameters
---
The timezone parameter is described as "A DateTimeZone object representing the
desired time zone". This is really ambiguous, since it depends on the user's
motivation for creating the DateTime object. For instance, I wanted to display a
UTC date string as a UK date string, so my "desired" timezone was
"Europe/London". That's not how it works, but because it says "desired",
that's
how it sounds like it works.
This sounds insignificant really, but I wasted an hour figuring out why it
wasn't working (date problems are tough because dates are affected by absolutely
everything in a system!), and I'm sure many other people have encountered the
same problem.
I suggest the timezone parameter should be described as "A DateTimeZone object
representing the timezone of the time parameter".
Thanks!
Test script:
---------------
// What someone would do who "desired" to convert a date from UTC to UK time...
$dateTime = new DateTime('2012-05-01 23:00:00UTC', 'Europe/London');
echo $dateTime->format("Y-m-d H:i:s e");
// produces...
// 2012-05-01 23:00:00 UTC
// The actual way to do it...
$dateTime = new DateTime('2012-05-01 23:00:00UTC');
$dateTime->setTimezone(new DateTimeZone('Europe/London'));
echo $dateTime->format("Y-m-d H:i:s e");
// produces...
// 2012-05-02 00:00:00 Europe/London
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61171&edit=1