title: How do you handle timezone difference calculation in PHP?
body: <p>I'm being told that this below method of calculating the user's local time is sometimes not working.  What's the best way to do this in PHP?  What do you do?</p>
  
  <pre><code>public function getTimeOffset ($time) {
      $this-&gt;_cacheTimeOffset();  
      if ($this-&gt;timeOffsetExecuted) {
          $d = date("O");
          $neg = 1;
  
          if (substr($d, 0, 1) == "-") {
              $neg = -1;
              $d = substr($d, 1);
          }
  
          $h = substr($d, 0, 2)*3600;
          $m = substr($d, 2)*60;
  
          return $time + ($neg * ($h + $m) * -1) + (($this-&gt;timeOffset + $this-&gt;getDstInUse()) * 3600);
      }
      return $time;
  }
  </code></pre>