A Unix timestamp (POSIX time) is an integer count of non-leap seconds (10 digits, e.g., 1792324800) or milliseconds (13 digits, e.g., 1792324800000) elapsed since 1970-01-01T00:00:00Z UTC, under the strict POSIX rule that every UTC calendar day equals exactly 86,400 seconds. You can convert any ISO 8601 date, local timezone string, or second/millisecond/nanosecond integer instantaneously in our Timestamp & Epoch Converter. Under the hood, storing timestamps as UTC-normalized 64-bit integers decouples databases, JWT exp claims, and distributed event logs from political Daylight Saving Time (DST) rule changes—provided you avoid three notorious systems traps: Python/SQL naive-datetime timezone shifts, the Year 2038 (Y2K38) 32-bit overflow, and POSIX leap-second replays.
| Runtime / CLI | Current Epoch (Seconds) | Parse UTC Date String -> Epoch | Format Epoch 1792324800 -> ISO 8601 UTC |
|---|---|---|---|
Linux (GNU coreutils date) |
date -u +%s |
date -u -d "2026-10-18T12:00:00Z" +%s |
date -u -d @1792324800 +"%Y-%m-%dT%H:%M:%SZ" |
macOS / FreeBSD (BSD date) |
date -u +%s |
TZ=UTC date -j -f "%Y-%m-%dT%H:%M:%SZ" "2026-10-18T12:00:00Z" +%s |
date -u -r 1792324800 +"%Y-%m-%dT%H:%M:%SZ" |
| JavaScript / TypeScript | Math.floor(Date.now() / 1000) |
Math.floor(Date.parse("2026-10-18T12:00:00Z") / 1000) |
new Date(1792324800 * 1000).toISOString() |
| Python 3.12+ | int(datetime.now(timezone.utc).timestamp()) |
int(datetime.fromisoformat("2026-10-18T12:00:00Z").timestamp()) |
datetime.fromtimestamp(1792324800, tz=timezone.utc).isoformat() |
Go (time) |
time.Now().Unix() |
t, _ := time.Parse(time.RFC3339, "2026-10-18T12:00:00Z"); t.Unix() |
time.Unix(1792324800, 0).UTC().Format(time.RFC3339) |
| PostgreSQL 18 | EXTRACT(EPOCH FROM now())::bigint |
EXTRACT(EPOCH FROM TIMESTAMPTZ '2026-10-18T12:00:00Z')::bigint |
to_timestamp(1792324800) AT TIME ZONE 'UTC' |
When inspecting unfamiliar JSON webhooks, Parquet columns, or binary traces, count the digits before dividing:
1792324800): Seconds (10^0 s) — POSIX time_t, OAuth2/JWT exp & iat, Stripe webhooks, date +%s.1792324800000): Milliseconds (10^-3 s) — JavaScript Date.now(), Java Instant.toEpochMilli(), Kafka record headers.1792324800000000): Microseconds (10^-6 s) — PostgreSQL internal TIMESTAMPTZ storage, Python datetime precision, Parquet TIMESTAMP_MICROS.1792324800000000000): Nanoseconds (10^-9 s) — Go UnixNano(), OpenTelemetry spans, Prometheus/ClickHouse/InfluxDB, Linux clock_gettime.Here is a trivia question that trips up senior backend engineers: How many actual physical SI seconds have elapsed since 1970-01-01T00:00:00Z when date +%s hits 1,800,000,000? The answer is 1,800,000,027 physical seconds, not 1,800,000,000!
Because Earth's rotational speed fluctuates slightly relative to International Atomic Time (TAI), the International Earth Rotation Service (IERS) has inserted 27 leap seconds (23:59:60 UTC) since 1972. Yet the POSIX.1 specification (§4.16 Seconds Since the Epoch) hardcodes a closed-form formula where every day contains strictly 86,400 seconds so timestamp % 86400 == 0 always lands cleanly on 00:00:00 UTC without consulting an external leap-second history table!
When a leap second occurs on an unconfigured Linux kernel (TIME_OOP), the kernel steps CLOCK_REALTIME backward by 1 full second at midnight, replaying the exact same Unix timestamp twice—causing database unique-timestamp violations, negative gettimeofday deltas, and high-CPU futex spin bugs! Modern datacenter fleets (and chrony with leapsecmode slew / smear) mitigate this via Leap Smearing: gently slewing the NTP reference clock by ~11.6 ppm across a 24-hour window so CLOCK_REALTIME advances monotonically without ever repeating a second. (Fortunately, the General Conference on Weights and Measures voted to retire UTC leap seconds by 2035!)
Y2K38) Overflow Is Already Breaking Code TodayLegacy 32-bit C systems defined time_t as a signed 32-bit integer (int32_t), whose maximum positive value is 2^31 - 1 = 2,147,483,647. Exactly one second after 2038-01-19T03:14:07Z, a signed 32-bit counter wraps around two's-complement arithmetic to -2,147,483,648—teleporting the system clock backward to December 13, 1901 (1901-12-13T20:45:52Z)!
Do not assume Y2K38 can wait until 2037! Forward-looking calculations—15-year financial amortizations, 20-year root CA certificates, long-lived IoT device provisioning, and MySQL TIMESTAMP columns—are hitting 2038-01-19 right now in 2026:
x86_64 and aarch64 Linux kernels (Ubuntu 24.04 LTS, Debian 12+) natively use 64-bit time_t (good for 292 billion years), and Ubuntu 24.04 transitioned remaining 32-bit armhf packages to time64_t (-D_TIME_BITS=64).TIMESTAMP vs PostgreSQL TIMESTAMPTZ): In MySQL/MariaDB, the TIMESTAMP column type is still a 4-byte 32-bit epoch integer that hard-fails on dates past 2038-01-19 03:14:07 UTC! By contrast, PostgreSQL TIMESTAMPTZ is an 8-byte signed 64-bit microsecond integer capable of representing dates up to 294,276 AD.utcnow() and PostgreSQL TIMESTAMP Timezone BugsTwo subtle code patterns silently add or subtract 5 to 8 hours from your Unix timestamps depending on which server runs the code:
datetime.utcnow().timestamp() Bug: Calling datetime.utcnow() creates a naive datetime object (tzinfo=None). In Python, calling .timestamp() on a naive datetime assumes the timestamp is in the machine's LOCAL timezone, not UTC! On a developer laptop in America/Chicago (UTC-5), datetime.utcnow().timestamp() silently shifts your Unix timestamp by 18,000 seconds (5 hours)! Python 3.12 officially deprecated utcnow(); always pass timezone.utc explicitly:# Python 3.12+: Timezone-aware UTC epoch conversions (immune to OS local TZ!)
from datetime import datetime, timezone
# 1. Current UTC Unix timestamp in seconds and milliseconds
now_utc = datetime.now(timezone.utc)
epoch_sec = int(now_utc.timestamp())
epoch_ms = int(now_utc.timestamp() * 1000)
# 2. Parse ISO 8601 string (with 'Z' or '+02:00' offset) -> UTC Unix seconds
parsed_sec = int(datetime.fromisoformat("2026-10-18T14:00:00+02:00").timestamp())
assert parsed_sec == 1792324800 # Identical to 12:00:00Z!
# 3. Convert Unix epoch integer -> timezone-aware UTC datetime
restored = datetime.fromtimestamp(1792324800, tz=timezone.utc)
print(restored.isoformat()) # 2026-10-18T12:00:00+00:00
TIMESTAMP vs TIMESTAMPTZ: In SQL, bare TIMESTAMP means TIMESTAMP WITHOUT TIME ZONE! If you store timestamps in a TIMESTAMP column and a reporting BI client connects with SET TIME ZONE 'America/New_York', running EXTRACT(EPOCH FROM created_at) interprets the stored digits as New York wall time and emits the wrong Unix epoch! Always declare columns as TIMESTAMPTZ (TIMESTAMP WITH TIME ZONE), which normalizes incoming offsets to pure UTC microseconds on write and guarantees EXTRACT(EPOCH FROM col) is invariant across every client TimeZone:-- Run via: psql -d app_db
-- ALWAYS use TIMESTAMPTZ (8 bytes, identical disk size to TIMESTAMP, 100% UTC-normalized!)
CREATE TABLE webhook_events (
id BIGSERIAL PRIMARY KEY,
received_at TIMESTAMPTZ NOT NULL DEFAULT now(),
expires_at TIMESTAMPTZ NOT NULL
);
-- Insert directly from a 10-digit Unix second integer (or divide 13-digit ms by 1000.0)
INSERT INTO webhook_events (expires_at)
VALUES (to_timestamp(1792324800)),
(to_timestamp(1792324800543 / 1000.0));
-- Extract exact integer Unix milliseconds for JSON API serialization
SELECT id, (EXTRACT(EPOCH FROM received_at) * 1000)::bigint AS received_epoch_ms
FROM webhook_events;
Yes! Any date prior to 1970-01-01T00:00:00Z—such as a user's date_of_birth in 1965 or historical financial records—is represented as a negative integer count of seconds before the epoch (for example, Apollo 11's lunar landing at 1969-07-20T20:17:40Z is Unix timestamp -14182940). Verify your API Zod/JSON schemas validate historical timestamps with z.number().int() rather than .nonnegative() if pre-1970 dates are valid!
new Date(1792324800) print a date in January 1970?JavaScript's Date constructor expects milliseconds since the epoch, not seconds! Passing a 10-digit second integer 1792324800 without multiplying by 1000 is interpreted as 1,792,324.8 seconds (~20.7 days) after January 1, 1970—landing on 1970-01-21T17:52:04.800Z. Always multiply 10-digit Unix seconds by 1000 (new Date(sec * 1000)), or paste unknown values into /tools/unix-timestamp-converter which auto-detects seconds, milliseconds, microseconds, and nanoseconds.
BIGINT integers or TIMESTAMPTZ in PostgreSQL?Use TIMESTAMPTZ! Under the hood, PostgreSQL already stores TIMESTAMPTZ as an 8-byte int64 (exact same 8 bytes per row and exact same B-tree index speed as BIGINT!), while giving you native interval arithmetic (now() - interval '7 days'), partition pruning by date range, date_trunc('hour', created_at), and human-readable psql output without manual conversions.
Run sudo timedatectl set-timezone UTC and sudo systemctl restart cron rsyslog (if installed). Standardizing every server across your fleet on UTC ensures journalctl, Nginx access logs, PostgreSQL logs, and cron schedules align second-for-second without twice-yearly Daylight Saving Time gaps or duplicate 1 AM cron executions!
Explore With AI & Cite This Page
Open a grounded prompt in your AI assistant or copy a clean Markdown, HTML, or APA reference link.
Validate protocols and subnets directly in your browser or continue reading related architecture notes.
Unix Timestamp Converter & Ms to Minutes
Cron to Systemd .timer & .service Generator
Free JWT Decoder, Base64URL & SHA-256 Tool
Milliseconds to Minutes for Systems Engineers: Timeout Budgets, Monotonic Clocks & Runtime Duration Parsing
Convert milliseconds to minutes accurately while avoiding real-world systems bugs: 32-bit setTimeout overflows, Go nanosecond traps, CLOCK_REALTIME leap-second jumps, and microservice timeout cascades.
Navigating the Linux Terminal: TTY Internals, Filesystem Semantics, and Production Operator Workflows
Go beyond basic cd and ls memorization: understand Linux pseudo-terminals (PTYs), VFS inodes, octal permissions, standard streams, systemd logs, and safe operator habits on cloud servers.
Converting Milliseconds to Minutes in Production: Cron Windows, SQL/PromQL Time Buckets & Telemetry Math
Beyond ms ÷ 60,000: how backend engineers map milliseconds to minutes across sliding-window rate limiters, PostgreSQL date_bin rollups, PromQL rate() normalization, Cron schedules, and drift-free integer telemetry formatting.
Production Incident Escalation, Self-Service Linux Diagnostics, and the ServersAreUp Support Runbook
A deterministic incident triage runbook for ServersAreUp engineers: isolating SDN vs guest OS faults with ss, journalctl, and mtr, plus escalating via /dashboard/support.