title: php date timezone issue
body: <p>I have PHP site which is running with some custom script. I store a last query date in the DB as UTC, like this:</p>
  
  <pre><code>$query = "UPDATE mytable SET last_query = UTC_TIMESTAMP() WHERE id = 1";
  </code></pre>
  
  <p>When the script executes, it grabs that last date and converts it to the local tz like this:</p>
  
  <pre><code>$sql = "SELECT last_query FROM mytable WHERE id = 1"; // grab date
  $result = $dbo-&gt;query($sql);
  $row    = $result-&gt;fetch();
  
  $last_query = new DateTime($row['last_query'], new DateTimeZone('UTC')); // build datetime
  
  $last_query-&gt;setTimezone(new DateTimeZone('America/Denver')); // set to local tz
  
  $last_query = $last_query-&gt;format('Y-m-d\TH:i:s'); // format
  
  $this-&gt;log('info', "Last queried: ".$last_query);
  </code></pre>
  
  <p>In my <code>phpinfo()</code>, <code>date.timezone = America/Denver</code> but the line for <code>Default timezone</code> shows <code>UTC</code>.</p>
  
  <p>I have an older logging script that prints a log line preceded by the date produced using <code>date</code>, like this: <code>$time = date( $this-&gt;DateFormat );</code> </p>
  
  <p>The problem is that in the log file, it shows the last query date as incorrect:</p>
  
  <pre><code>2016-07-05 12:00:02 - INFO  --&gt; Last queried: 2016-07-05T18:00:02
  </code></pre>
  
  <p>The date of the log message (<code>2016-07-05 12:00:02</code>) is correct-- the date of the <code>last_query</code> as you can see is 6hrs ahead (or UTC time).</p>
  
  <p>What am I missing in my date conversion (or possibly in the PHP ini?) that is causing this mismatch? I'm assuming that I'm wrong to instantiate the <code>DateTime</code> object with the <code>UTC</code> timezone, but despite reading a lot of documentation on timezones I am still unclear.</p>
  
  <p>EDIT: the <code>last_query</code> column is a mysql <code>TIMESTAMP</code> field</p>