Unix Timestamp Explained
Unix time counts seconds since January 1, 1970 UTC (epoch), widely used in APIs, logs, and databases.
Quick answer
Unix timestamp (epoch time) is integer seconds since 1970-01-01 00:00:00 UTC, excluding leap seconds in common POSIX interpretation. JavaScript Date often uses milliseconds since epoch—multiply or divide by 1000 when converting. Timestamps are timezone-agnostic; display local time requires explicit timezone conversion.
Overview
APIs return `created_at: 1716460800` instead of human dates to keep JSON compact and timezone-neutral at storage. Developers convert epoch to local display for admin UIs and back to epoch for query filters. Confusion between seconds and milliseconds causes dates in year 1970 or 50000+ when wrong unit assumed. Signed 32-bit timestamps overflow January 2038 (Y2038 problem)—modern systems use 64-bit. Logs aggregate by epoch range for performance; always confirm API docs whether value is seconds, milliseconds, or microseconds since epoch.
Epoch definition and UTC baseline
Epoch start: 1970-01-01 00:00:00 UTC, not local midnight—local display of epoch zero differs by timezone offset.
Count increases monotonically one per second in idealized POSIX time; leap seconds handled inconsistently across systems—rare issue for app devs but matters in finance tick data.
Seconds vs milliseconds vs microseconds
Unix classic: seconds (10 digits currently ~1.7e9). JavaScript Date.now() milliseconds (13 digits). Some APIs microseconds (16 digits). Identify magnitude by digit count heuristic.
Convert ms to s: divide by 1000 floor. Python datetime.fromtimestamp expects seconds float; JS new Date(ms) expects ms.
Timezone neutrality and display
Store UTC epoch; convert to local or named timezone only at presentation layer. Never store local epoch without offset documentation—that pattern causes bugs.
Daylight saving transitions affect local clock strings but not UTC epoch increment continuity.
Y2038 and integer width
32-bit signed max 2147483647 → 2038-01-19 UTC. Legacy embedded systems risk; modern 64-bit languages default safe. Database column types int vs bigint for timestamps on long-lived data.
Validate API contracts for bit width when integrating mainframe or IoT devices.
API filters, caching, and logs
Query `?since=timestamp` for incremental sync. Cache keys include epoch version for busting. Log correlation uses epoch ordering independent of locale string sort bugs on '03/04/2024' formats.
Pair epoch storage with ISO 8601 strings in APIs needing human readability—document canonical format.
Examples
1716460800 seconds
2024-05-23 12:00:00 UTC approximately—verify with converter for exact local display.
JavaScript pitfall
Passing seconds to new Date(1716460800) interprets as ms → 1970 date; use new Date(1716460800 * 1000).
Common mistakes and edge cases
- Seconds vs milliseconds confusion.
- Formatting epoch with local timezone in stored database value.
- 32-bit overflow assumptions on new projects.
- Sorting date strings DD/MM vs MM/DD instead of epoch in code.
Related resources
Related tools
Last reviewed: 2026-05-23