擅长:python、mysql、java
<p>这个怎么样?我想它可以用来处理1970年之前和2038年之后的日期。</p>
<pre class="lang-py prettyprint-override"><code>target_date_time_ms = 200000 # or whatever
base_datetime = datetime.datetime( 1970, 1, 1 )
delta = datetime.timedelta( 0, 0, 0, target_date_time_ms )
target_date = base_datetime + delta
</code></pre>
<p>如Python标准库中所述:</p>
<blockquote>
<p>fromtimestamp() may raise ValueError, if the timestamp is out of the
range of values supported by the platform C localtime() or gmtime()
functions. It’s common for this to be restricted to years in 1970
through 2038.</p>
</blockquote>