Convert Unix timestamps in Python using the `datetime` and `time` modules.
import time
# Get current timestamp (seconds)
timestamp = int(time.time())
print(timestamp)from datetime import datetime
# Date to timestamp
dt = datetime(2024, 1, 1)
timestamp = int(dt.timestamp())from datetime import datetime
# Timestamp to date
ts = 1704067200
dt = datetime.fromtimestamp(ts)
print(dt.strftime('%Y-%m-%d %H:%M:%S'))