Unix Timestamp Converter
What It Is
This tool converts Unix epoch timestamps to human-readable dates and vice versa, supporting both seconds and millisecond precision. Developers use it constantly when debugging authentication tokens (JWT exp claims), inspecting database records, correlating log entries across distributed systems, or resolving timezone-related integration bugs.
How It Works
The Unix epoch counts seconds elapsed since 1970-01-01T00:00:00Z, ignoring leap seconds. The new Date(timestamp * 1000) constructor converts second-precision values into JavaScript Date objects. From there, toISOString() produces UTC time in ISO 8601 format, toLocaleString() applies the browser's timezone offset, and toUTCString() renders RFC 7231 format used in HTTP headers. The reverse conversion (date.getTime() / 1000) rounds to whole seconds.
Worked Example
Input: timestamp 1710086400 in seconds mode. Outputs: Local time - "3/10/2024, 12:00:00 PM" (America/New_York); ISO 8601 - "2024-03-10T16:00:00.000Z"; UTC string - "Sun, 10 Mar 2024 16:00:00 GMT"; Unix milliseconds - "1710086400000". The reverse conversion of "2024-03-10T16:00:00.000Z" via new Date("2024-03-10T16:00:00.000Z").getTime() / 1000 returns the original 1710086400.
Common Mistakes
- Mixing seconds and milliseconds. Passing a millisecond value (e.g.,
Date.now()returns milliseconds) into an API expecting seconds produces a date in the year 5138. Always divide by 1000 before sending to epoch-second endpoints. - Assuming timestamps are timezone-aware. Unix timestamps are always UTC. Storing "local" timestamps without offset metadata is unrecoverable - the same epoch value represents different wall-clock times across timezones.
- Ignoring leap seconds. The Unix epoch explicitly ignores leap seconds, meaning a timestamp can be exactly one second off from UTC during a leap-second event. This is negligible for most applications but critical for high-frequency trading or astronomy.
Frequently Asked Questions
Q:What is Unix timestamp and why is it used?
Unix timestamp (also called epoch time) is the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC. It is widely used in programming, databases, and APIs because it provides a simple numeric representation of time that is independent of timezones and daylight saving time.
Q:What is the difference between Unix seconds and milliseconds?
Unix seconds are the standard epoch timestamp counted in seconds (e.g., 1704067200). Milliseconds are the same epoch value multiplied by 1000 (e.g., 1704067200000). JavaScript Date objects use milliseconds, while many APIs and JSON standards use seconds.
Q:Is this timestamp converter accurate for all timezones?
This converter shows both local time (your browser timezone) and UTC/GMT time. Unix timestamps themselves are always in UTC. The tool converts the same epoch value to your local timezone for convenience, making it useful for debugging timezone-related issues in applications.
Q:What is the Year 2038 problem?
The Year 2038 problem affects 32-bit signed integers storing Unix timestamps: the maximum value 2^31 - 1 = 2147483647 corresponds to January 19, 2038 at 03:14:07 UTC. One second later it overflows to a negative number. Most modern systems use 64-bit integers, which extend the limit to about 292 billion years.
Q:How do I get the current Unix timestamp in different languages?
In JavaScript: <code>Math.floor(Date.now() / 1000)</code>. In Python: <code>int(time.time())</code>. In Go: <code>time.Now().Unix()</code>. In SQL: <code>UNIX_TIMESTAMP()</code> (MySQL) or <code>EXTRACT(EPOCH FROM NOW())</code> (PostgreSQL).