title: Converting GMT time to local time using timezone offset, not timezone identifier
body: <p>It's pretty easy to convert a given GMT date into local time if you're given the timezone identifier from this list in PHP: <a href="http://www.php.net/manual/en/timezones.php" rel="nofollow">http://www.php.net/manual/en/timezones.php</a></p>
  
  <p>For example, you can do this (where $fromTimeZone is just 'GMT', $toTimeZone is just one of the constants from that list (i.e. 'America/Chicago'), and $datetime is the GMT date):</p>
  
  <pre><code>public static function convertToTimezone($datetime, $fromTimeZone, $toTimeZone, $format = 'Y-m-d H:i')
  {
      // Construct a new DateTime object from the given time, set in the original timezone
      $convertedDateTime = new DateTime($datetime, timezone_open($fromTimeZone));
      // Convert the published date to the new timezone
      $convertedDateTime-&gt;setTimezone(timezone_open($toTimeZone));
      // Return the udpated date in the format given
      return $convertedDateTime-&gt;format($format);
  }
  </code></pre>
  
  <p>However, I'm having issue converting the same GMT date to the local time if just given the timezone offset. For instance, instead of being given 'America/Chicago', I'm given -0500 (which is the equivalent offset for that timezone).</p>
  
  <p>I've tried things such as the following (where $datetime is my GMT date and $toTimeZone is the offset (-0500 in this case)):</p>
  
  <pre><code>date($format, strtotime($datetime . ' ' . $toTimeZone))
  </code></pre>
  
  <p>I know all the date() sort of functions are based on the servers's timezone. I just can't seem to get it to ignore that and use a timezone offset that is given explicitly.</p>