title: JavaScript timestamp to Python datetime conversion
body: <p>To get timestamp in JavaScript we use </p>
  
  <pre><code>var ts = new Date().getTime()
  </code></pre>
  
  <p>What is the proper way to convert it to a Python <code>datetime</code> so far I use the following code</p>
  
  <pre><code>&gt;&gt;&gt; jsts = 1335205804950
  &gt;&gt;&gt; dt = datetime.datetime.fromtimestamp(jsts/1000)
  &gt;&gt;&gt; dt
  datetime.datetime(2012, 4, 24, 0, 30, 4)
  </code></pre>
  
  <p>I divide timestamp by 1000 because I get error like </p>
  
  <pre><code>ValueError                                Traceback (most recent call last)
  1 d = datetime.datetime.fromtimestamp(a)
  ValueError: year is out of range
  </code></pre>
  
  <p>Sultan.</p>