The Unix timestamp given by:
int(time.time())
gives the number of seconds elapsed since 01/01/1970, without leap-seconds.
Just out of curiosity, how to get the true number of seconds elapsed since this date, leap-seconds included? (i.e. the distance between these two events on a time axis)
Notes:
Example: the timestamp range
867715190.000 .. 867715202.000
represents a "real-life duration" of 13 seconds (measured with a timer) because there was a leap-second this day of 1997, whereas the Unix timestamp has only increased of +12.Example 2: the real-life time elapsed between 1/1/1970 and 1/1/2020 (12 leap-years in this 50-year interval) is
(365*50+12)*24*3600 + number_leap_seconds
and not(365*50+12)*24*3600
. But we seedatetime.datetime.utcfromtimestamp((365*50+12)*24*3600)
is2020-01-01 00:00:00
, so obviously, the leap-seconds haven't been taken in consideration.Linked to What does python return on the leap second, and Unix time and leap seconds