According to the definition of Unix time, it measures the number of seconds that have elapsed since 00:00 UTC on January 1st 1970. However, when I run datetime.fromtimestamp(0)
using python 3.8, I get 1970-01-01 01:00:00
. Why is it 1AM and not 00:00?
Timezones!!!
Try this:
from datetime import *
print(datetime.fromtimestamp(0, timezone.utc))
This gets the epoch time in UTC (+00:00)