title: Timezone issues on new XAMPP install with PHP 5.3
body: <p>In response to the announcement that WordPress 3.2 (due later this month) <a href="http://codex.wordpress.org/Version_3.2" rel="nofollow">will require PHP 5.2.4+</a>, I upgraded my Windows test machine today from XAMPP 1.5.5 to 1.7.4, which in turn bumped me up from PHP 5.2.0 to 5.3.5.</p>
  
  <p>I've got just about everything working again, but one test page is behaving strangely.  I have a MySQL table with tz identifiers by country code and the following script determines and displays the current time in each of the timezones:</p>
  
  <pre><code>&lt;?php
    echo "&lt;table&gt;";
    $result = mysql_query("SELECT * FROM zone_data ORDER BY `id` ASC;");
    while ($row = mysql_fetch_assoc($result)) {
      putenv("TZ=".$row['zone_name']);
      echo "&lt;tr&gt;";
        echo "&lt;th&gt;".$row['zone_code']."&lt;/th&gt;";
        echo "&lt;td&gt;".$row['zone_name']."&lt;/td&gt;";
        echo "&lt;td&gt;".date("D j M Y / H:i T",$_GET['t']);
          if (date("I") == 1) { echo "*"; } // asterisk if in DST
        echo " (".date("P",$_GET['t']).")&lt;/td&gt;";
      echo "&lt;/tr&gt;";
    }
    echo "&lt;/table&gt;";
  ?&gt;
  </code></pre>
  
  <p>The expected output, which runs just fine on the production server in PHP 5.2.17, should be along the lines of:</p>
  
  <pre><code>Z   Etc/UTC          Fri 3 Jun 2011 / 03:22 UTC (+00:00)
  AD  Europe/Andorra   Fri 3 Jun 2011 / 05:22 CEST* (+02:00)
  AE  Asia/Dubai       Fri 3 Jun 2011 / 07:22 GST (+04:00)
  AF  Asia/Kabul       Fri 3 Jun 2011 / 07:52 AFT (+04:30)
  AG  America/Antigua  Thu 2 Jun 2011 / 23:22 AST (-04:00)
  ...
  </code></pre>
  
  <p>...but instead I'm told that the time is the same as my system time, <code>America/New_York</code> (currently UTC-4) in <strong>every</strong> zone:</p>
  
  <pre><code>Z   Etc/UTC          Thu 2 Jun 2011 / 23:22 EDT* (-04:00)
  AD  Europe/Andorra   Thu 2 Jun 2011 / 23:22 EDT* (-04:00)
  AE  Asia/Dubai       Thu 2 Jun 2011 / 23:22 EDT* (-04:00)
  ...
  </code></pre>
  
  <p>Now, I <em>had</em> noticed that line 1001 of the new <code>php.ini</code> installed with XAMPP 1.7.4 had originally contained <code>date.timezone = Europe/Berlin</code>, so I'd replaced it with <code>date.timezone = America/New_York</code>.  But in both cases, <strong>every</strong> instance of the <code>date()</code> function is being dictated by this setting regardless of anything I've said otherwise with <code>putenv()</code>.  The same holds true for all other pages using <code>date()</code> (although <code>gmdate()</code>, obviously, returns GMT as expected).</p>
  
  <p>I tried commenting out that line, but PHP 5.3.5 threw <em>lovely</em> errors saying that it's "not safe to rely on the system's timezone settings" and that I'm <em>required</em> to use the <code>date.timezone</code> directive in <code>php.ini</code>, even though I always use <code>putenv()</code> when I use <code>date()</code> or similar functions.</p>
  
  <p>It's a bit frustrating to be forced to make a "super-global" setting, especially for a case like this where the <strong>whole point</strong> is to temporarily enter a new TZ environment and glean some useful information from it.</p>
  
  <p><strong>So...</strong> Is there any way I can have the <code>date.timezone</code> directive behave as a default that is overridable by <code>putenv()</code> such that the latter isn't completely ignored?  Is there anything else you can think of that might be causing the unexpected/bizarre behavior outlined above?</p>
  
  <p>I'm inclined to believe that this is just some server setting that needs to be changed to allow <code>putenv()</code> to continue working in PHP 5.3.5 as it did in 5.2.0 (and does in 5.2.17).  Of course, if there's a "better way" altogether, I wouldn't mind hearing about it (I always like learning new things!).  But mostly I want my old code to work on my new install.</p>
  
  <p>Let me know if you need any more information about my setup.</p>