Unix Timestamp
Convert between timestamps and dates
What Is a Unix Timestamp?
A Unix timestamp (also called an epoch timestamp) is the number of seconds that have elapsed since January 1, 1970 00:00:00 UTC, not counting leap seconds. It is the most compact, timezone-neutral way to store a point in time and is used by databases, APIs, log files, JWTs, and virtually every system-level interface.
Seconds vs. Milliseconds
Two variants are in common use. POSIX timestamps count whole seconds (e.g., 1700000000). JavaScript's Date.now() and many REST APIs return millisecond timestamps (e.g., 1700000000000). A millisecond timestamp is always 13 digits; a second timestamp is 10 digits for dates between 2001 and 2286. The converter above auto-detects the unit by checking whether the value exceeds 1e12.
Common Uses in Development
- JWT expiry (
exp): Theexpclaim is always in whole seconds, not milliseconds. A common bug is passingDate.now()directly, which produces a timestamp 1000× too far in the future. - Database storage: Storing timestamps as integers avoids timezone conversion issues and is faster to index than ISO strings in most databases.
- Cache headers: HTTP's
Expiresheader uses RFC 1123 date strings, butCache-Control: max-ageuses a duration in seconds relative to the request time. - Log correlation: When comparing logs across services, converting all timestamps to UTC ISO 8601 (
toISOString()) eliminates local-timezone ambiguity.
Year 2038 Problem
Systems that store Unix timestamps in a signed 32-bit integer will overflow on January 19, 2038 at 03:14:07 UTC. Modern 64-bit systems and languages are not affected, but embedded firmware and some legacy databases may be. The converter on this page uses JavaScript's 64-bit floating-point numbers, which safely handle dates well beyond the year 9999.