A complete, human-friendly guide on how to convert from epoch time to readable dates across languages, databases, CLI, and spreadsheets, with examples, best practices, and a free ZenixTools converter.
If you work with logs, analytics, APIs, or databases, you’ll often need to convert from epoch time to a readable date. This guide explains what epoch (Unix) time is, why it matters, and exactly how to convert it using online tools, code, spreadsheets, and databases. We’ll also cover common mistakes, best practices, and expert tips to avoid time-zone and unit pitfalls.
Featured Snippet (Quick Answer): To convert from epoch time, first detect units: seconds (10 digits) or milliseconds (13 digits). Convert seconds directly; divide milliseconds by 1000. Then interpret in UTC and format to an ISO 8601 date, e.g., 2024-06-15T12:30:00Z. In Python: datetime.utcfromtimestamp(SECONDS). In JavaScript: new Date(MILLISECONDS). Use a reliable tool or library and confirm time zone.
AI Overview (150 words max): Need to convert from epoch time? Identify the unit (seconds vs. milliseconds), pick a time zone (usually UTC), then use a tool or code to format the result. Online converters are fastest. In code, use standard libraries: Python’s datetime.utcfromtimestamp, JavaScript’s new Date(ms), PostgreSQL’s to_timestamp, MySQL’s FROM_UNIXTIME, or Excel’s epoch-to-date formula. Watch out for common errors like mixing ms and s, applying local time unintentionally, or truncating instead of rounding. Best practice: store timestamps in UTC, document units, and output ISO 8601 (e.g., 2024-06-15T12:30:00Z). This guide includes step-by-step instructions, real examples, and a comparison table to help you choose the right approach.
“Convert from epoch time” means turning a Unix timestamp into a human-readable date and time. Epoch (or Unix) time is the number of seconds (or milliseconds) elapsed since the Unix epoch: 1970-01-01T00:00:00Z (UTC). It’s a compact, time-zone-neutral way to track moments across systems.
Key points:
When you convert from epoch time, you take the numeric timestamp, interpret it in UTC, then format it as a standard date string like 2024-06-15T12:30:00Z or 2024-06-15 12:30:00 +00:00.
Accurate conversion prevents data misalignment, wrong charts, and confused users.
Tip: If the number is 13 digits, it’s likely milliseconds. To get seconds, divide by 1000 (floor or round as needed).
const ms = 1718454600000; // 13 digits
const d = new Date(ms); // UTC inside, prints in local by default
console.log(d.toISOString()); // 2024-06-15T12:30:00.000Z
const s = 1718454600; // 10 digits
const d = new Date(s * 1000);
console.log(d.toISOString());
from datetime import datetime, timezone
s = 1718454600
dt_utc = datetime.fromtimestamp(s, tz=timezone.utc) # 2024-06-15 12:30:00+00:00
print(dt_utc.isoformat())
ms = 1718454600000
dt_utc2 = datetime.fromtimestamp(ms / 1000, tz=timezone.utc)
print(dt_utc2.isoformat())
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
long seconds = 1718454600L;
Instant instant = Instant.ofEpochSecond(seconds);
String iso = DateTimeFormatter.ISO_INSTANT.format(instant); // UTC
System.out.println(iso);
long ms = 1718454600000L;
Instant instantMs = Instant.ofEpochMilli(ms);
System.out.println(DateTimeFormatter.ISO_INSTANT.format(instantMs));
$seconds = 1718454600;
echo gmdate('c', $seconds); // ISO 8601 in UTC
$ms = 1718454600000;
echo gmdate('c', (int)($ms / 1000));
package main
import (
"fmt"
"time"
)
func main() {
s := int64(1718454600)
t := time.Unix(s, 0).UTC()
fmt.Println(t.Format(time.RFC3339))
ms := int64(1718454600000)
t2 := time.UnixMilli(ms).UTC()
fmt.Println(t2.Format(time.RFC3339))
}
s = 1718454600
puts Time.at(s).utc.iso8601
ms = 1718454600000
puts Time.at(ms / 1000.0).utc.iso8601
using System;
long s = 1718454600;
var dtUtc = DateTimeOffset.FromUnixTimeSeconds(s).UtcDateTime;
Console.WriteLine(dtUtc.ToString("o"));
long ms = 1718454600000;
var dtUtc2 = DateTimeOffset.FromUnixTimeMilliseconds(ms).UtcDateTime;
Console.WriteLine(dtUtc2.ToString("o"));
# Seconds to ISO 8601 UTC
SECONDS=1718454600
date -u -d @"$SECONDS" +"%Y-%m-%dT%H:%M:%SZ"
# Milliseconds
MS=1718454600000
SECONDS=$((MS / 1000))
date -u -d @"$SECONDS" +"%Y-%m-%dT%H:%M:%SZ"
# Seconds
$s = 1718454600
[DateTimeOffset]::FromUnixTimeSeconds($s).UtcDateTime.ToString("o")
# Milliseconds
$ms = 1718454600000
[DateTimeOffset]::FromUnixTimeMilliseconds($ms).UtcDateTime.ToString("o")
-- Seconds to timestamp (UTC)
SELECT to_timestamp(1718454600) AT TIME ZONE 'UTC';
-- Milliseconds
SELECT to_timestamp(1718454600000 / 1000.0) AT TIME ZONE 'UTC';
-- Seconds to datetime (session time zone applies)
SELECT FROM_UNIXTIME(1718454600);
-- Force UTC display (if needed)
SET time_zone = '+00:00';
SELECT FROM_UNIXTIME(1718454600);
-- Seconds to UTC
SELECT datetime(1718454600, 'unixepoch');
-- Milliseconds to UTC
SELECT datetime(1718454600000 / 1000, 'unixepoch');
-- Seconds -> TIMESTAMP
SELECT TIMESTAMP_SECONDS(1718454600);
-- Milliseconds -> TIMESTAMP
SELECT TIMESTAMP_MILLIS(1718454600000);
-- Seconds to TIMESTAMP_NTZ (no time zone)
SELECT TO_TIMESTAMP(1718454600);
-- Milliseconds
SELECT TO_TIMESTAMP(1718454600000 / 1000);
| Method | Skill Required | Speed | Accuracy | Best For | Notes |
|---|---|---|---|---|---|
| ZenixTools Online Converter | Low | Very Fast | High | Quick checks, non-tech users | Auto-detects units, copies ISO, no setup |
| JavaScript (Date) | Low | Fast | High | Web apps, Node scripts | new Date(ms) prints local by default; use toISOString() |
| Python (datetime) | Low-Med | Fast | High | Data science, ETL | Use timezone.utc and isoformat() |
| Bash date | Med | Fast | High | DevOps, shells | Requires GNU date; use -u for UTC |
| Excel/Sheets | Low | Med | Med |
What is epoch time? Epoch (Unix) time is the number of seconds (or milliseconds) since 1970-01-01T00:00:00Z (UTC). It’s a numeric way to represent a moment in time.
How do I tell if my timestamp is in seconds or milliseconds? Count digits: 10 digits is usually seconds; 13 digits is milliseconds. If in doubt, divide by 1000 and sanity-check the resulting date.
How do I convert from epoch time in JavaScript? Use new Date(ms) for milliseconds or new Date(s * 1000) for seconds, then d.toISOString() for UTC output.
How do I convert from epoch time in Python? Use datetime.fromtimestamp(SECONDS, tz=timezone.utc) or datetime.fromtimestamp(MS/1000, tz=timezone.utc) and call .isoformat().
What time zone is epoch time? UTC. Always convert in UTC first, then localize for display if needed.
Why does my result show a different local time? Because many functions default to your system’s local time. Use UTC-aware methods and ISO 8601 (Z) to avoid confusion.
How do I convert in Excel or Google Sheets? Assuming seconds in A2: =A2/86400 + DATE(1970,1,1). Format as date/time. For milliseconds: =(A2/1000)/86400 + DATE(1970,1,1). Adjust for time zone if needed.
How do I convert in PostgreSQL? SELECT to_timestamp(seconds) AT TIME ZONE 'UTC'; For milliseconds: to_timestamp(ms/1000.0) AT TIME ZONE 'UTC'.
What about Year 2038 problems? On 32-bit systems using signed 32-bit seconds, timestamps overflow in 2038. Modern 64-bit systems and languages avoid this, but legacy code may need updates.
Why are milliseconds common in JS? JavaScript Date uses milliseconds since epoch by design, so many web systems standardize on ms for precision.
How do I ensure consistent formatting? Use ISO 8601 with UTC (e.g., 2024-06-15T12:30:00Z). Avoid locale-dependent strings like 06/15/24 12:30 PM.
Converting correctly from epoch time comes down to a few reliable steps: detect units, interpret in UTC, and format to ISO 8601. Whether you prefer code, SQL, spreadsheets, or an online tool, following the best practices in this guide will keep your data accurate and comparable across systems and teams. When in doubt—or when speed matters—use ZenixTools to quickly convert from epoch time with confidence.
Try the free ZenixTools Epoch Time Converter now. Paste a timestamp, auto-detect units, and copy a clean ISO 8601 UTC date in seconds. For pipelines and teams, explore our Time Zone Converter, ISO 8601 Formatter, CSV Batch Unix Converter, and JSON Date ↔ Epoch tools to standardize time across your stack.
Learn how to convert 1 meter to feet with precise formulas, quick methods, and real-world examples. Includes best practices, common mistakes, comparison tables, FAQs, and expert tips for accurate length conversions.
Learn how to convert 1 meter to feet with the exact formula, step-by-step instructions, quick mental math, and real-world examples. Includes charts, best practices, FAQs, and expert tips.
| Analysts, CSV exports |
| Needs formulas; time-zone handling is limited |
| PostgreSQL | Med | Fast | High | Warehouses, analytics | to_timestamp + AT TIME ZONE 'UTC' |
| MySQL/MariaDB | Med | Fast | High | Apps, reporting | FROM_UNIXTIME; manage session time_zone |
| BigQuery/Snowflake | Med | Fast | High | Cloud analytics | Dedicated epoch functions |
How do I handle daylight saving time (DST)? Store and convert in UTC; only apply a local time zone at presentation. Use reliable time-zone libraries when needed.
Can I convert from microseconds or nanoseconds? Yes, divide to seconds with appropriate precision (us/1e6, ns/1e9) and use libraries that preserve sub-second precision.
How do I convert large CSVs of epochs? Use Python/Pandas, SQL, or cloud warehouses. Normalize units, convert in UTC, and export in ISO 8601 to prevent parsing errors.
Is there a quick online tool? Yes—use the free ZenixTools Epoch Time Converter to auto-detect units and copy ISO/UTC results instantly.