Alexandre B A Villares 🐍<p>Hoje eu aprendi a converter um <a href="https://ciberlandia.pt/tags/datetimestamp" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>datetimestamp</span></a> unix em uma data legível com <a href="https://ciberlandia.pt/tags/Python" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Python</span></a> <a href="https://ciberlandia.pt/tags/datetime" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>datetime</span></a> </p><pre><code>from datetime import datetime<br>ts = int('1284101485')<br><br># if you encounter a "year is out of range" error the timestamp<br># may be in milliseconds, try `ts /= 1000` in that case<br>print(datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))<br></code></pre><p><a href="https://stackoverflow.com/a/3682808/19771" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">stackoverflow.com/a/3682808/19</span><span class="invisible">771</span></a></p>