title: Confusion converting from epoch timestamp in Python
body: <p>I have the following simple script (using Python 3.4).</p>
  
  <pre><code>from dateutil.parser import *
  import datetime
  d1 = "1490917274299"
  d2 = "1490917274"
  </code></pre>
  
  <p>1) When executing <code>datetime.datetime.fromtimestamp(int(d1)).strftime('%c')</code>, the following error raises:</p>
  
  <pre><code>&gt;&gt;&gt; datetime.datetime.fromtimestamp(int(d1)).strftime('%c')
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  OverflowError: timestamp out of range for platform time_t
  </code></pre>
  
  <p>2) I've read that avoiding milliseconds solves the issue. So I divide <code>d1/1000</code> to get <code>d2</code> and voilà!</p>
  
  <pre><code>&gt;&gt;&gt; datetime.datetime.fromtimestamp(int(d2)).strftime('%c')
  'Thu Mar 30 23:41:14 2017'
  </code></pre>
  
  <p>3) However, if I want to use <code>parse(d2)</code> I get an error.</p>
  
  <pre><code>&gt;&gt;&gt; parse(d2)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/local/lib/python3.4/dist-packages/dateutil/parser.py", line 1168, in parse
      return DEFAULTPARSER.parse(timestr, **kwargs)
    File "/usr/local/lib/python3.4/dist-packages/dateutil/parser.py", line 578, in parse
      if cday &gt; monthrange(cyear, cmonth)[1]:
    File "/usr/lib/python3.4/calendar.py", line 121, in monthrange
      day1 = weekday(year, month, 1)
    File "/usr/lib/python3.4/calendar.py", line 113, in weekday
      return datetime.date(year, month, day).weekday()
  ValueError: year is out of range
  </code></pre>
  
  <p>4) If you try to <code>parse(d1)</code> you also get an error:</p>
  
  <pre><code>&gt;&gt;&gt; parse(d1)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/local/lib/python3.4/dist-packages/dateutil/parser.py", line 1168, in parse
      return DEFAULTPARSER.parse(timestr, **kwargs)
    File "/usr/local/lib/python3.4/dist-packages/dateutil/parser.py", line 578, in parse
      if cday &gt; monthrange(cyear, cmonth)[1]:
    File "/usr/lib/python3.4/calendar.py", line 121, in monthrange
      day1 = weekday(year, month, 1)
    File "/usr/lib/python3.4/calendar.py", line 113, in weekday
      return datetime.date(year, month, day).weekday()
  OverflowError: Python int too large to convert to C long
  </code></pre>
  
  <p>5) Finally, if you use <code>d1</code> in <a href="https://www.epochconverter.com/" rel="nofollow noreferrer">https://www.epochconverter.com/</a>, you'll correctly get the intended date.</p>
  
  <p>Why is this happening at all? I just wanted a way of checking if a string is a datetime by the use of <code>parse()</code> but is not working eventhouhg the epoch string is fine (at least d2).</p>
  
  <p>On the other hand, why is d1 not fine as epoch?</p>
  
  <p>Thanks!</p>
  
  <p>Lucas</p>