EpochTools

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 browser

JavaScript 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 guide

Python

time and datetime modules

Python 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 guide

PHP

time(), date() and gmdate()

PHP returns seconds directly from `time()`, no division needed. Format them with `date()` (server-local) or `gmdate()` (UTC).

View guide

Java

java.time API

Java's legacy `System.currentTimeMillis()` returns milliseconds. The modern `java.time` package makes the rest trivial: `Instant` is the epoch-friendly representation.

View guide

SQL

MySQL & PostgreSQL

Both 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 guide

Go

time.Unix

Go 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 guide

Rust

SystemTime and chrono

The standard library exposes epoch seconds through `SystemTime::now().duration_since(UNIX_EPOCH)`. For ergonomic formatting most projects reach for the `chrono` crate.

View guide

C#

.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