Developer reference
Get the Unix timestamp in any language
Short, copy-paste guides for reading the current epoch time and converting timestamps to human-readable dates — plus an embedded converter on every page.
Not sure what you're converting? Learn what a Unix epoch time is, or try the main Unix timestamp converter first.
JavaScript
Node.js and browserJavaScript uses millisecond-precision timestamps everywhere. `Date.now()` returns the current epoch in milliseconds, so divide by 1000 (and floor) for the classic 10-digit second value.
View guidePython
time and datetime modulesPython keeps two time APIs: `time` for raw floats and `datetime` for objects. `time.time()` returns a float in seconds; `int()` truncates it to the classic epoch value.
View guidePHP
time(), date() and gmdate()PHP returns seconds directly from `time()`, no division needed. Format them with `date()` (server-local) or `gmdate()` (UTC).
View guideJava
java.time APIJava's legacy `System.currentTimeMillis()` returns milliseconds. The modern `java.time` package makes the rest trivial: `Instant` is the epoch-friendly representation.
View guideSQL
MySQL & PostgreSQLBoth MySQL and PostgreSQL have first-class functions for epoch conversion. `UNIX_TIMESTAMP()` / `extract(epoch from now())` read the current time; the reverse direction formats a timestamp for display.
View guideGo
time.UnixGo uses `time.Now()` for an instant and `time.Unix(sec, nsec)` to build one from epoch parts. Unlike many languages, Go encourages nanoseconds via `UnixNano()`.
View guideRust
SystemTime and chronoThe standard library exposes epoch seconds through `SystemTime::now().duration_since(UNIX_EPOCH)`. For ergonomic formatting most projects reach for the `chrono` crate.
View guideC#
.NET DateTimeOffset.NET stores dates as ticks since 0001-01-01, so epoch conversion always involves an offset from `DateTimeOffset.FromUnixTimeSeconds()` and `ToUnixTimeSeconds()`.
View guide