Epoch & Unix Timestamp in Python
Get the current epoch timestamp
import time
epoch_seconds = int(time.time()) Convert epoch to date
from datetime import datetime, timezone
dt = datetime.fromtimestamp(1718200000, tz=timezone.utc) Convert date to epoch
from datetime import datetime, timezone
epoch = int(datetime(2026, 6, 12, tzinfo=timezone.utc).timestamp()) Python notes
time.time() returns float seconds. Always pass tz=timezone.utc to fromtimestamp — without it the result is silently converted to local time.
Check any value live with the epoch converter, or read what Unix time actually counts.
Other languages
C · C# · C++ · Dart · Go · Java · JavaScript · Kotlin · MySQL · Perl · PHP · PostgreSQL · R · Ruby · Rust · Scala · SQLite · Swift · TypeScript