Guide
How to Convert Epoch Time to a Human-Readable Date
A practical guide to converting Unix timestamps into readable dates across popular programming languages, with online tools and timezone-aware examples.
What is epoch time?
Epoch time (also called Unix time or POSIX time) is the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970. It is the universal standard for representing moments in time in computing. Every programming language and operating system supports epoch time natively, making it the most reliable format for storing and exchanging timestamps between systems.
Step 1 — Identify your timestamp format
Before converting, determine whether your timestamp is in seconds or milliseconds:
- 10 digits (e.g. 1700000000) → seconds since the Unix epoch
- 13 digits (e.g. 1700000000000) → milliseconds since the Unix epoch
- If in doubt, divide by 1000 and check whether the year looks reasonable
- You can also paste the timestamp into the converter above and it will auto-detect
Converting epoch to date in JavaScript
JavaScript's Date constructor accepts milliseconds. If your timestamp is in seconds, multiply by 1000 first.
- new Date(1700000000 * 1000).toISOString() → '2023-11-15T06:13:20.000Z'
- new Date(1700000000 * 1000).toUTCString() → 'Wed, 15 Nov 2023 06:13:20 GMT'
- new Date(1700000000 * 1000).toLocaleString('en-US', { timeZone: 'America/New_York' })
- new Date(1700000000000).getTime() → 1700000000000 (milliseconds back)
Converting epoch to date in Python
Python's datetime module provides fromtimestamp() for local time and utcfromtimestamp() for UTC. For explicit timezone handling use the timezone.utc parameter.
- datetime.datetime.fromtimestamp(1700000000) → local timezone
- datetime.datetime.fromtimestamp(1700000000, tz=datetime.timezone.utc) → UTC (Python 3.2+)
- datetime.datetime.fromtimestamp(1700000000).strftime('%Y-%m-%d %H:%M:%S') → formatted string
- datetime.datetime.fromtimestamp(1700000000, tz=datetime.timezone.utc).isoformat() → ISO 8601
Converting epoch to date in PHP
PHP's built-in date() and DateTime class both support Unix timestamps directly.
- date('Y-m-d H:i:s', 1700000000) → '2023-11-15 06:13:20' (server's local timezone)
- gmdate('Y-m-d H:i:s', 1700000000) → '2023-11-15 06:13:20' (always UTC)
- $dt = new DateTime(); $dt->setTimestamp(1700000000); $dt->format('c') → ISO 8601
Converting epoch to date in Go
Go's time package converts Unix timestamps with time.Unix(seconds, nanoseconds).
- time.Unix(1700000000, 0) → time.Time in local timezone
- time.Unix(1700000000, 0).UTC() → force UTC
- time.Unix(1700000000, 0).Format(time.RFC3339) → '2023-11-15T06:13:20Z'
- time.Unix(1700000000, 0).Format('2006-01-02 15:04:05') → custom layout
Common mistakes when converting epoch time
The most frequent errors when working with Unix timestamps:
- Forgetting to multiply seconds by 1000 in JavaScript — new Date(1700000000) gives the year 1970, not 2023
- Using JavaScript milliseconds directly as seconds in a server-side language
- Not specifying a timezone and relying on the server's local timezone, which varies between environments
- Storing timestamps as strings instead of integers, which breaks numeric comparisons and arithmetic