FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16822&edit=1

ID: 16822
Updated by: steve@tracepointgps.com
Reported By: steve at tracepointgps dot com
Summary: setTZByID() does not behave as expected
Status: Open
Type: Bug
Package: Date
Operating System: CentOS
Package Version: 1.4.7
PHP Version: 5.2.5
Roadmap Versions:
New Comment:

Corrections to test script.

/** Test of Date class demonstrating how setTZByID() does not work as
expected. */
include ("Date.php");
// initialize object
$timestamp = 1258918447;
$d = new Date($timestamp);
$d->setTZByID("GMT");
$timestampGMT = $d->getTime();
echo "Local Time: " . date("m/d/Y h:i:s A O", $timestamp) . " timestamp
= $timestamp <br />";
echo "Time in GMT: " . $d->format("%D %r %O") . " timestamp =
$timestampGMT <br />";


Previous Comments:
------------------------------------------------------------------------

[2009-11-22 20:34:07] steve_tp

Description:
------------
Perhaps this is an expectation problem. I instantiate a new Date
object with a timestamp $x = new Date(time());
and then set the timezone
$x->setTZByID("GMT");
I expect the timestamp to remain the same, and the date to now be
reported in GMT, but the date and time are now reported inconsistently.

Am I interpreting this wrong somehow?

Test script:
---------------
<?php
/** Test of Date class demonstrating how setTZByID() does not work as
expected.
*/
include ("/Date.php");
// initialize object
$timestamp = 1258918447;
$d = new Date($timestamp);
$d->setTZByID("GMT");
$timestampGMT = $d->getTime();
echo "Local Time: " . date("m/d/Y h:i:s A O") . " timestamp =
$timestamp <br />";
echo "Time in GMT: " . $d->format("%D %r %O") . " timestamp =
$timestampGMT <br />";
?>

Expected result:
----------------
Local Time: 11/22/2009 02:34:07 PM -0500 timestamp = 1258918447
Time in GMT: 11/22/2009 07:34:07 PM +00:00 timestamp = 1258918447

Actual result:
--------------
Local Time: 11/22/2009 02:34:07 PM -0500 timestamp = 1258918447
Time in GMT: 11/22/2009 02:34:07 PM +00:00 timestamp = 1258918447

Note: on 2nd line, timestamp and time are now inconsidtent.

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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedNov 22, '09 at 7:50p
activeNov 22, '09 at 7:50p
posts1
users1
websitepear.php.net

1 user in discussion

Steve: 1 post

People

Translate

site design / logo © 2021 Grokbase