title: Python Convert UTC to PST / PDT format
body: <p>I have a web app that captures date / time via a JS script and calculates seconds since epoch in UTC format - ex 134250270000. In the backend we have a Python script that fetches data from DB but has date / time stored in number of seconds since epoch in PST format. There is always a difference of seconds between UTC and PST if counted from epoch.</p>
  
  <p>Is there any method by which I can convert the UTC seconds since to epoch to PST seconds since epoch? We need to take a note of daylight changes in PST timezone also?</p>
  
  <p>EDIT::</p>
  
  <pre><code>I have the seconds since epoch in UTC format:
  
  1342502700
  
  I found that I get the sum in seconds between UTC and local standard time via:
  
  &gt;&gt;&gt; time.timezone / 3600
  8
  
  So If I add 1342502700 to time.timezone:
  
  &gt;&gt;&gt; print 1342502700 + time.timezone
  1344153600
  </code></pre>
  
  <p>Will it always give me PDT / PST times correctly? </p>
  
  <p>EDIT::</p>
  
  <p>Maybe this is the correct one:</p>
  
  <pre><code>&gt;&gt;&gt; import time
  &gt;&gt;&gt; offset = time.timezone if (time.daylight == 0) else time.altzone
  &gt;&gt;&gt; offset / 60 / 60
  7
  </code></pre>
  
  <p>time.daylight will be non-zero if daylight savings is currently in effect.</p>