UNIX Time in Python

UNIX time started on January 1, 1970 UTC.

The get the current UNIX time in Python run:

from time import time

time()

As I'm writing this the current time is:

1672936981.4351747

The integers are seconds, and before the decimal are fractions of seconds. To get the integer value:

int(time())

It is easy to work back from the current UNIX TIME:

- 10 : 10 seconds ago

- 60 : 1 minute ago

- 60*60 : 1 hour ago

- 60*60*24: 1 day ago

- 60*60*24*7 : 1 week ago

etcetera.

Comments