title: PHP UTC to Local Time
body: <p><strong>Server Environment</strong></p>
  
  <p>Redhat Enterprise Linux<br>
  PHP 5.3.5</p>
  
  <p><strong>Problem</strong></p>
  
  <p>Let's say I have a UTC date and time such as 2011-04-27 02:45 and I want to 
  convert it to my local time, which is America/New_York.</p>
  
  <p><strong>Three questions:</strong></p>
  
  <p>1.) My code below might solve the problem, would you agree? </p>
  
  <pre><code>&lt;?php
  
  date_default_timezone_set('America/New_York');  // Set timezone.
  
  $utc_ts = strtotime("2011-04-27 02:45");  // UTC Unix timestamp.
  
  // Timezone offset in seconds. The offset for timezones west of UTC is always negative,
  // and for those east of UTC is always positive.
  $offset = date("Z");
  
  $local_ts = $utc_ts + $offset;  // Local Unix timestamp. Add because $offset is negative.
  
  $local_time = date("Y-m-d g:i A", $local_ts);  // Local time as yyyy-mm-dd h:m am/pm.
  
  echo $local_time;  // 2011-04-26 10:45 PM
  
  ?&gt;
  </code></pre>
  
  <p>2.) But, does the value of $offset automatically adjust for Daylight Savings Time (DST) ?<br>
  3.) If not, how should I tweak my code to automatically adjust for DST ?<br /><br />Thank you :-)</p>