Unix Timestamp in Python
Look up the current epoch time and convert between Unix seconds and UTC dates in Python.
Get the current timestamp
import time
print(time.time_ns() // 1_000_000_000)Timestamp to date
from datetime import datetime, timezone
print(datetime.fromtimestamp(1_700_000_000, timezone.utc).isoformat())Date to timestamp
from datetime import datetime, timezone
from math import floor
print(floor(datetime(2023, 11, 14, 22, 13, 20, tzinfo=timezone.utc).timestamp()))Open 1700000000 in the converter
Current Unix time
Seconds—
Milliseconds—
- UTC
- —
- My time zone
- —
Free to use. Your input stays in this browser.
How to use it
- Copy the current-time example into your Python environment to read Unix seconds.
- Run the second example to display 1700000000 as a UTC date.
- Run the last example to convert that date back into seconds.
Use a timezone-aware datetime. A naive datetime is interpreted as local time by timestamp(), which can shift the result between machines.