The Python Oracle

In Python, how do you convert seconds since epoch to a `datetime` object?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC H Dvoks String Quartet No 12 Ame

--

Chapters
00:00 Question
00:31 Accepted answer (Score 530)
00:56 Answer 2 (Score 57)
01:11 Answer 3 (Score 48)
01:36 Answer 4 (Score 10)
02:18 Thank you

--

Full question
https://stackoverflow.com/questions/3694...

Accepted answer links:
[datetime.datetime.fromtimestamp]: http://docs.python.org/library/datetime....

Answer 2 links:
[datetime]: http://docs.python.org/2/library/datetim...
[strftime]: http://docs.python.org/2/library/datetim...

Answer 3 links:
[Python 3]: https://docs.python.org/3.5/library/date...
[Python 2]: https://docs.python.org/2/library/dateti...
[pytz]: http://pytz.sourceforge.net/

Answer 4 links:
[fromtimestamp]: http://docs.python.org/2/library/datetim...
[utcfromtimestamp]: http://docs.python.org/2/library/datetim...
[This may raise ValueError, if the timestamp is out of the range of
values supported by the platform C gmtime() function. It’s common for
this to be restricted to years in 1970 through 2038]: http://docs.python.org/2/library/datetim...
[Issue1646728]: http://bugs.python.org/issue1646728

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #datetime #date #time #epoch

#avk47