Using PHP DateTime to parse and convert timezone PST to PDT (GMT -8 to GMT -7)
<p>I am having difficulty using PHP <code>DateTime</code> to convert a date received with a GMT -8 timezone (PST) to a human readable format with timezone GMT -7 (PDT).</p>

<p>Here's an example:</p>

<pre><code>$tz = new DateTimeZone('America/Los_Angeles');  
$saleEndDate = new DateTime("2016-11-07T17:30:00-08:00");
$saleEndDate-&gt;setTimezone($tz);
echo $saleEndDate-&gt;format('Y-m-d H:i:s');
</code></pre>

<p>The output of the above code is: <strong>2016-11-07 17:30:00</strong>. However, it should display <strong>2016-11-07 18:30:00</strong> because <code>America/Los_Angeles</code> is now in daylight savings (GMT -7, PDT).</p>

<p>From what I've read in the <a href="http://php.net/manual/en/datetime.createfromformat.php" rel="nofollow">DateTime docs</a>, the <code>new DateTime</code> command should be able to interpret that the string <code>2016-11-07T17:30:00-08:00</code> has a GMT -8 timezone:</p>

<blockquote>
  <p>The <strong>timezone</strong> parameter and the current timezone are ignored when the <strong>time</strong> parameter either contains a UNIX timestamp (e.g. 946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00).</p>
</blockquote>

<p>Even so, I do not think <code>DateTime</code> is recognizing GMT -8 correctly.</p>

<p>Does anyone know what approach is necessary to convert between timezones correctly?</p>

<p><strong>Update:</strong></p>

<p>I've also tried passing in a <code>DateTimeZone</code> as the second parameter to the <code>DateTime</code> constructor, but also to no avail:</p>

<pre><code>$tz = new DateTimeZone('America/Los_Angeles');  
$saleEndDate = new DateTime("2016-11-07T17:30:00-08:00", new DateTimeZone("America/Los_Angeles"));
$saleEndDate-&gt;setTimezone($tz);
echo $saleEndDate-&gt;format('Y-m-d H:i:s');
</code></pre>

<p>Also does not work:</p>

<pre><code>$tz = new DateTimeZone('America/Los_Angeles');  
$saleEndDate = new DateTime("2016-11-07T17:30:00", new DateTimeZone("PST"));
$saleEndDate-&gt;setTimezone($tz);
echo $saleEndDate-&gt;format('Y-m-d H:i:s');
</code></pre>

<p>Also does not work:</p>

<pre><code>$tz = new DateTimeZone("PDT");  
$saleEndDate = new DateTime("2016-11-07T17:30:00", new DateTimeZone("PST"));
$saleEndDate-&gt;setTimezone($tz);
echo $saleEndDate-&gt;format('Y-m-d H:i:s');
</code></pre>