Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0a4

Bug #12529 setTZ globally sets your TZ instead of only within date object
Submitted: 2007-11-26 18:56 UTC
From: bgolub Assigned: c01234
Status: Closed Package: Date (version 1.4.7)
PHP Version: 5.2.0 OS: Debian
Roadmaps: (Not assigned)    
Subscription  


 [2007-11-26 18:56 UTC] bgolub (Benjamin Golub)
Description: ------------ Calling setTZ sets the TZ globally instead of only within the date object. See the test script for var_dumps that shows this. Test script: --------------- var_dump(getenv("TZ")); $date = new Date(); $date->setTZ("US/Pacific"); var_dump($date->tz->getOffset($date) / 1000); var_dump(getenv("TZ")); string(0) "" int(-28800) string(10) "US/Pacific" Expected result: ---------------- I expected getenv("TZ") to return "" Actual result: -------------- getenv("TZ") returns "US/Pacific"

Comments

 [2007-11-27 12:35 UTC] c01234 (Chuckie Chuck)
Actually, it is getOffset(), not setTZ(), that is setting the TZ env. variable globally. It does this as a side effect, because instead of working out whether the date is in Summer time, it delegates this to the native PHP functions. However, as these work in the machine's local time zone, it needs to set the TZ globally. It is supposed to reset it to the original value, but it does not work properly. In CVS, this implementation is no longer used, so this bug has already been fixed.
 [2008-03-23 23:10 UTC] c01234 (Chuckie Chuck)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Date