A Unix timestamp represents elapsed seconds since the Unix Epoch (January 1, 1970 00:00:00 UTC), serving as the universal standard for date-time representation.
A Unix Timestamp (also referred to as Epoch Time, POSIX Time, or UNIX Time) is an integer or floating-point numerical representation of time, measured as the total number of elapsed seconds since the Unix Epoch—defined as 00:00:00 UTC on Thursday, January 1, 1970 (excluding leap seconds).
Because Unix timestamps are timezone-agnostic and monotonic, they are universally employed in database engines, REST/gRPC APIs, message queues, JSON Web Tokens (JWT), and system logs to represent discrete instants in time without ambiguity.
Convert, format, and inspect Unix timestamps across all timezones with our client-side Unix Timestamp Converter tool and calculate multi-city team schedules with the Timezone Converter.
While original POSIX specifications defined timestamps in whole seconds, modern distributed architectures operate across varying resolutions:
| Precision Level | Decimal Digits | Typical Integer Representation | Common Systems & Runtimes |
|---|---|---|---|
| Seconds ($s$) | 10 digits | 1715629200 |
POSIX time_t, Python time.time(), Redis TTL, JWT exp/iat, MySQL UNIX_TIMESTAMP() |
| Milliseconds ($ms$) | 13 digits | 1715629200000 |
JavaScript Date.now(), Java System.currentTimeMillis(), MongoDB ISODate |
| Microseconds ($\mu s$) | 16 digits | 1715629200000000 |
Python datetime.now().timestamp(), PostgreSQL timestamptz, Apache Cassandra |
| Nanoseconds ($ns$) | 19 digits | 1715629200000000000 |
Go time.Now().UnixNano(), Rust SystemTime, Linux kernel clock, InfluxDB |
The Year 2038 Problem (also called the Unix Millennium Bug) arises on systems storing Unix timestamps in 32-bit signed integers (int32):
Modern 64-bit architectures (int64) expand this limit to $2^{63} - 1 \approx 9.22 \times 10^{18}$ seconds, which guarantees precision for approximately 292 billion years into the future.
International Atomic Time (TAI) counts continuous physical seconds. Because the Earth's rotational speed fluctuates, the International Earth Rotation and Reference Systems Service (IERS) periodically inserts leap seconds into UTC to keep solar time aligned.
However, standard POSIX Unix time does not count leap seconds. A standard POSIX day is rigidly defined as having exactly 86,400 seconds ($24 \times 60 \times 60$). When a leap second occurs (such as 23:59:60 UTC), POSIX systems handle it via leap-smearing (gradually slowing the clock over several hours) or by repeating the timestamp 23:59:59 to maintain arithmetic compatibility ($t_2 - t_1 = 86400$).
// Current timestamp in seconds and milliseconds
const epochMs = Date.now();
const epochSec = Math.floor(epochMs / 1000);
// Converting Unix epoch to ISO 8601 UTC string
const isoString = new Date(epochMs).toISOString();
// Output: "2024-05-13T19:40:00.000Z"
// Converting ISO date string back to Unix seconds
const seconds = Math.floor(new Date("2024-05-13T19:40:00.000Z").getTime() / 1000);
import time
from datetime import datetime, timezone
# Get current Unix timestamp (float with microsecond precision)
now_epoch = time.time()
epoch_seconds = int(now_epoch)
# Convert epoch to timezone-aware UTC datetime
dt = datetime.fromtimestamp(epoch_seconds, tz=timezone.utc)
iso_formatted = dt.isoformat()
# Output: "2024-05-13T19:40:00+00:00"
package main
import (
"fmt"
"time"
)
func main() {
// Current Unix timestamp
sec := time.Now().Unix()
nano := time.Now().UnixNano()
// Convert epoch seconds to UTC time.Time
t := time.Unix(sec, 0).UTC()
fmt.Println(t.Format(time.RFC3339))
}
use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
let now = SystemTime::now();
let duration = now.duration_since(UNIX_EPOCH).expect("Time went backwards");
let seconds = duration.as_secs();
let millis = duration.as_millis();
println!("Epoch seconds: {}, millis: {}", seconds, millis);
}
-- PostgreSQL: Convert epoch to TIMESTAMPTZ and back
SELECT TO_TIMESTAMP(1715629200) AT TIME ZONE 'UTC';
SELECT EXTRACT(EPOCH FROM NOW())::BIGINT;
-- MySQL: Convert epoch to DATETIME and back
SELECT FROM_UNIXTIME(1715629200);
SELECT UNIX_TIMESTAMP(NOW());
TIMESTAMPTZ in PostgreSQL). Never store ambiguous local time strings without timezone offsets.Z suffix (e.g. 2024-05-13T19:40:00.000Z) eliminate client-side parsing ambiguity.Free, browser-based utilities to test, generate, and inspect Unix Timestamp (Epoch Time) & POSIX Time payloads directly.
Convert between Unix timestamps, ISO 8601, and human-readable dates instantly.
Convert between time zones and find the best meeting times across cities.
Parse, validate, explain, and build cron expressions with next run times and visual timeline.
Decode, inspect, and validate JWT tokens with claim and signature analysis.
Generate, validate, and decode UUIDs, ULIDs, and Nano IDs instantly.