Timestamp in Python
How to work with timestamp Python — getting the current Unix timestamp, converting between timestamps and datetime objects in Python.
Timestamp Converter
--
--
--
--
--
Convert seconds to human time
--
--
Current Timestamp in Python
import time
int(time.time()) # seconds
int(time.time()*1000) # milliseconds
Timestamp to Date in Python
from datetime import datetime
datetime.fromtimestamp(1700000000) # local time
datetime.utcfromtimestamp(1700000000) # UTC time
Date to Timestamp in Python
from datetime import datetime
dt = datetime(2023, 11, 14, 22, 13, 20)
int(dt.timestamp()) # seconds