Epoch Time to Date: How Unix Timestamps Work
What Is Epoch Time
Epoch time, also called Unix timestamp or Unix time, is a way to represent a specific moment in time as a single number: the number of seconds that have passed since January 1, 1970, 00:00:00 UTC.
This starting point is called the "Unix epoch." It's a standardized reference point used across almost all computer systems and programming languages.
The timestamp 1700000000 represents November 14, 2023, at approximately 22:13:20
UTC.
Why January 1, 1970?
The Unix epoch was chosen in the early 1970s when the Unix operating system was being developed. The date was arbitrary but practical:
- It was a convenient round number in the recent past
- It made date calculations simpler for early computers
- It became a de facto standard across Unix systems
- Most programming languages adopted it for consistency
Fun fact: Timestamps before January 1, 1970 are negative numbers. For
example, December 31, 1969 23:59:59 UTC is -1.
Seconds vs Milliseconds
Unix timestamps come in two common formats:
| Format | Digits | Example | Used By |
|---|---|---|---|
| Seconds | 10 digits | 1700000000 | Unix/Linux systems, databases, APIs |
| Milliseconds | 13 digits | 1700000000000 | JavaScript, Java, some APIs |
How to Tell the Difference
- 10 digits = seconds (standard Unix timestamp)
- 13 digits = milliseconds (JavaScript
Date.now()format)
Milliseconds provide more precision, useful for measuring short durations or precise event timing. Learn more in our seconds vs milliseconds guide.
Timezones and Timestamps
Here's a key concept that confuses many developers: the Unix timestamp itself is always UTC.
What This Means
- The timestamp
1700000000represents the exact same moment worldwide - It's always counted from 1970-01-01 00:00:00 UTC
- Timezone only affects how the timestamp is displayed, not the timestamp value
Timestamp: 1700000000
- UTC: November 14, 2023, 22:13:20
- New York (EST): November 14, 2023, 17:13:20
- Tokyo (JST): November 15, 2023, 07:13:20
Same moment. Different clock readings. Same timestamp.
Don't adjust timestamps for timezone. The timestamp is already timezone-independent. Only convert to local time when displaying to users.
How to Convert Epoch to Date
Converting a Unix timestamp to a human-readable date involves these steps:
Step 1: Identify the Format
Check if your timestamp is in seconds (10 digits) or milliseconds (13 digits).
Step 2: Convert to Milliseconds (if needed)
If your timestamp is in seconds, multiply by 1000 to get milliseconds. Most programming languages expect milliseconds for date conversion.
Step 3: Create a Date Object
Pass the milliseconds to your language's date constructor.
Step 4: Format for Display
Convert the date object to your desired format, applying timezone if needed.
For a detailed walkthrough, see our how to convert Unix timestamp to date guide.
Common Use Cases
- APIs and databases — Store and compare timestamps easily
- Log files — Record precise event times
- Caching — Set expiration times in seconds
- Scheduling — Calculate future dates from now
- Debugging — Convert timestamps in error logs to readable times
- Session management — Track user activity timestamps
Common Mistakes
- Confusing seconds and milliseconds — Using a 13-digit timestamp where 10 digits are expected
- Adding timezone offset to the timestamp — Timestamps are already UTC
- Storing local time as a timestamp — Always store UTC, convert on display
- Ignoring negative timestamps — Dates before 1970 have negative values
- Not handling timestamp overflow — 32-bit systems have a Year 2038 problem
The Year 2038 Problem
On 32-bit systems, Unix timestamps are stored as signed 32-bit integers. This means they can only represent dates up to January 19, 2038. After that, the timestamp will overflow and wrap around to a negative number, potentially causing issues in legacy systems.
Modern 64-bit systems don't have this limitation, as 64-bit timestamps can represent dates billions of years into the future.