How to Convert Epoch to Human-Readable Date
An Epoch timestamp (also referred to as Unix time or POSIX time) represents the cumulative elapsed duration since the Unix Epoch: January 1, 1970 at 00:00:00 UTC, excluding leap seconds.
To translate a numeric timestamp back into a recognizable human date format, a computer performs simple arithmetic by adding the timestamp value to the base epoch date:
Because Unix timestamps are inherently coordinated in UTC, converting an epoch timestamp to a localized date requires offsetting the UTC time by your target timezone offset (e.g., UTC+05:30 for Indian Standard Time, UTC-05:00 for Eastern Standard Time).
Timestamp Precision: Seconds vs. Milliseconds to Date
One of the most frequent programming bugs is mismatching timestamp units. Modern web APIs, databases, and message brokers utilize varying degrees of temporal precision:
Standard Unix format. Used in Python, PHP, Linux core utilities, and standard SQL databases.
Standard JavaScript format (Date.now()). 1,000 milliseconds equal 1 second.
High-frequency database logs, distributed tracing, and Python time.time_ns() // 1000.
Low-latency networking, kernel metrics, and Go time.Now().UnixNano().
Convert Timestamp to Date in Code (JavaScript, Python, Go, SQL)
Copy and paste these verified snippets directly into your projects to convert epoch timestamps to readable date objects:
// From Seconds: Multiply by 1000 const dateFromSec = new Date(1730123456 * 1000); console.log(dateFromSec.toISOString()); // e.g. "2024-10-28T13:50:56.000Z" // From Milliseconds: Direct constructor const dateFromMs = new Date(1730123456789); console.log(dateFromMs.toLocaleString()); // Local formatted string
from datetime import datetime, timezone
# Convert seconds to UTC datetime
timestamp = 1730123456
dt_utc = datetime.fromtimestamp(timestamp, tz=timezone.utc)
print(dt_utc.strftime("%Y-%m-%d %H:%M:%S UTC"))
# If your timestamp is in milliseconds:
dt_ms = datetime.fromtimestamp(1730123456789 / 1000.0, tz=timezone.utc)-- PostgreSQL: SELECT to_timestamp(1730123456); -- MySQL: SELECT FROM_UNIXTIME(1730123456); -- MySQL with milliseconds: SELECT FROM_UNIXTIME(1730123456789 / 1000);
package main
import (
"fmt"
"time"
)
func main() {
tm := time.Unix(1730123456, 0).UTC()
fmt.Println(tm.Format(time.RFC3339))
}Frequently Asked Questions: Epoch to Date
Why does JavaScript return January 1970 when I convert my timestamp?
JavaScript's new Date(value) expects milliseconds (13 digits), whereas typical Unix timestamps from Unix/Linux or backend databases are in seconds (10 digits). If you provide seconds directly, JavaScript evaluates it as 1.7 million milliseconds (less than an hour into January 1, 1970). Multiply your seconds by 1000 to resolve this.
Are Unix timestamps affected by Daylight Saving Time (DST)?
No. Unix timestamps are strictly based on UTC (Coordinated Universal Time), which does not observe Daylight Saving Time. DST only comes into effect when presenting the timestamp in a localized regional timezone.
Can an Epoch timestamp be negative?
Yes. Negative timestamps represent dates occurring prior to January 1, 1970. For example, -315360000 represents January 1, 1960 00:00:00 UTC.
Related Timestamp & Developer Tools
Convert standard calendar dates back into Unix timestamps.
Live ticking clock with seconds, milliseconds, and ISO string.
Compare timestamps across UTC, EST, PST, GMT, and IST.
Bulk parse multiple timestamps and export to CSV or JSON.
Add or subtract days, hours, or seconds from any timestamp.
UUID, Base64, JSON formatter, and hash tools in one suite.
