Learn how to convert epoch time to readable dates and back. Practical steps, code examples, best practices, and mistakes to avoid. Built for developers, analysts, and anyone who handles timestamps.
If you work with logs, APIs, or databases, you’ll often need to epoch time convert values into readable dates—and back again. This guide explains epoch (Unix) time in plain language, shows fast ways to convert it, and helps you avoid common mistakes. Whether you’re a developer or an analyst, you’ll learn practical steps you can trust.
Epoch time, also called Unix time, is the number of seconds (or milliseconds) since January 1, 1970 UTC. To convert epoch to a readable date, use a converter tool, your operating system’s date command, or code (e.g., JavaScript’s new Date(epoch) for milliseconds or new Date(epoch * 1000) for seconds). Always confirm if your timestamp is in seconds or milliseconds.
Epoch time is a universal way to record time as a single integer since Jan 1, 1970 UTC. Use online tools (like ZenixTools), command-line utilities, or code in languages such as JavaScript, Python, and Java to convert between epoch and human-readable dates. Watch for units (seconds vs milliseconds), time zones, and daylight saving time. Follow best practices: standardize to UTC, store integers, and test edge cases.
“Epoch time convert” refers to turning a Unix timestamp into a human-readable date and time, and vice versa. Unix time measures the number of seconds (or milliseconds) since the Unix epoch: January 1, 1970 at 00:00:00 UTC.
Key points:
Why it’s used:
Note: Epoch time differs from local time. UTC is the base. Local time adds an offset (e.g., UTC-05:00).
You’ll find epoch time in:
iat, OAuth tokens)Being able to epoch time convert values on demand helps you debug, audit, and report faster—with fewer errors.
Tip: Standardize storage in UTC. Convert only when displaying to users.
Warning: Converting with the wrong unit can shift your date by ~1000x.
Note: ZenixTools auto-detects units in many cases and highlights time-zone context.
Linux/macOS (GNU date):
# Epoch seconds -> human (UTC)
date -u -d @1704067200
# Epoch seconds -> human (local)
date -d @1704067200
# Human -> epoch seconds (UTC)
date -u -d "2026-01-01 00:00:00" +%s
BSD/macOS (BSD date):
# Human -> epoch seconds (UTC)
date -u -j -f "%Y-%m-%d %H:%M:%S" "2026-01-01 00:00:00" +%s
Windows PowerShell:
# Epoch seconds -> human (local)
$epoch = 1704067200
[DateTimeOffset]::FromUnixTimeSeconds($epoch).DateTime
# Human -> epoch seconds (UTC)
([DateTimeOffset]::Parse("2026-01-01T00:00:00Z")).ToUnixTimeSeconds()
JavaScript:
// Epoch seconds -> Date (local display)
const sec = 1704067200;
const d1 = new Date(sec * 1000);
// Epoch milliseconds -> Date
const ms = 1704067200000;
const d2 = new Date(ms);
// Date -> epoch seconds/milliseconds
const now = new Date();
const epochMs = now.getTime();
const epochSec = Math.floor(epochMs / 1000);
Python:
import datetime, time
# Epoch seconds -> datetime (UTC)
sec = 1704067200
dt_utc = datetime.datetime.utcfromtimestamp(sec)
# Datetime -> epoch seconds (UTC)
dt = datetime.datetime(2026, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)
epoch_sec = int(dt.timestamp())
Java:
import java.time.*;
long sec = 1704067200L;
Instant instant = Instant.ofEpochSecond(sec);
ZonedDateTime utc = instant.atZone(ZoneOffset.UTC);
long nowSec = Instant.now().getEpochSecond();
long nowMs = Instant.now().toEpochMilli();
PHP:
// Epoch seconds -> DateTime (UTC)
$sec = 1704067200;
$dt = (new DateTime('@' . $sec))->setTimezone(new DateTimeZone('UTC'));
// DateTime -> epoch seconds
$epoch = (new DateTime('2026-01-01T00:00:00Z'))->getTimestamp();
Go:
import (
"time"
)
sec := int64(1704067200)
t := time.Unix(sec, 0).UTC()
now := time.Now().UTC()
epochSec := now.Unix()
epochMs := now.UnixMilli()
SQL (PostgreSQL):
-- Epoch seconds -> timestamp (UTC)
SELECT to_timestamp(1704067200) AT TIME ZONE 'UTC';
-- Timestamp -> epoch seconds
SELECT EXTRACT(EPOCH FROM TIMESTAMP '2026-01-01 00:00:00+00');
Example (Python):
import pytz, datetime
sec = 1704067200
utc = datetime.datetime.utcfromtimestamp(sec).replace(tzinfo=pytz.UTC)
ny = utc.astimezone(pytz.timezone('America/New_York'))
exp and iat.Instant/ZonedDateTime (Java), datetime with tz (Python), and Date/Temporal (JS, when available) to avoid silent zone bugs.Z or include offset.TIMESTAMP WITH TIME ZONE or store epoch as BIGINT and convert in views.| Method | Best For | Accuracy | Time Zone Handling | Offline | Speed | Notes |
|---|---|---|---|---|---|---|
| ZenixTools Epoch Converter | Quick checks, sharing results | High | Easy: switch UTC/local/IANA | Yes (web/app) | Fast | Auto-detects units, formats ISO/RFC |
| Command Line (date/PowerShell) | Scripting, servers | High | Good with flags | Yes | Fast | Requires correct syntax per OS |
| Language Libraries (JS/Python/Java) | Apps, ETL, APIs | High | Excellent with IANA support | Yes | Very fast | Best for production code |
| Manual Math | Rare, controlled cases | Medium | Poor | Yes | Fast | Risky; avoid for DST/offsets |
What is epoch time? Epoch time (Unix time) counts the seconds or milliseconds since Jan 1, 1970 UTC. It’s a simple numeric way to represent time across systems.
How do I tell if my timestamp is in seconds or milliseconds? Check the length: seconds are usually 10 digits; milliseconds are usually 13 digits. Also confirm with documentation or by converting and seeing if the result makes sense.
How do I convert epoch time to a readable date?
Use ZenixTools, your OS date command, or code. Example in JavaScript: new Date(epoch * 1000) for seconds, or new Date(epoch) for milliseconds.
Why does the converted time show a different hour? You are seeing your local time zone. Convert in UTC to compare systems. Many tools let you toggle UTC vs local time.
What is the 2038 problem? On 32-bit systems, epoch seconds overflow in 2038. Use 64-bit integers and modern libraries to avoid it. Most modern systems are safe.
Do leap seconds affect epoch time? Unix time ignores leap seconds. Most systems “smear” them, so timestamps remain monotonic for practical use.
Should I store epoch in seconds or milliseconds? Store the precision you need. Seconds are enough for logs. Milliseconds help with high-frequency events. Document your choice.
How do I convert a local date to epoch?
Parse the local date with a time zone, convert to UTC, then to epoch. In Python, set tzinfo and use .timestamp().
What is ISO 8601 / RFC 3339?
A standard format for timestamps like 2026-01-01T00:00:00Z. It’s precise, unambiguous, and easy to parse across systems.
How do I handle daylight saving time? Use IANA time zones (e.g., America/Los_Angeles) and trusted libraries. Don’t hardcode fixed offsets.
Why do my logs sort wrong by time? You may be sorting strings with mixed formats. Sort by epoch integers or normalized ISO 8601 UTC strings.
iat, nbf, exp claims)Epoch time convert tasks are simple once you know the units, time zone context, and formatting rules. Use UTC for storage, ISO 8601 for strings, and reliable tools for everyday work. With ZenixTools and the tips above, you can convert between Unix timestamps and readable dates confidently, avoid errors, and speed up debugging and analysis.
Ready to convert timestamps with confidence? Open the ZenixTools Epoch Converter now. Paste your timestamp, choose seconds or milliseconds, and get clean UTC and local outputs. Explore our Time Zone Converter and ISO 8601 Formatter to build a complete, accurate time workflow.
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.
Master converting from kilometers to miles with exact formulas, quick mental math, charts, and real examples. Written for travelers, runners, students, and pros.
Can I convert epoch time without internet?
Yes. Use the OS date command, PowerShell, or code libraries. ZenixTools offers lightweight options too.
How do I convert between time zones? Convert epoch to UTC, then apply the target IANA time zone using libraries or tools that know DST rules.
How do I validate a timestamp field in JSON?
Use JSON Schema with format: "date-time" for ISO strings, or define a custom integer field for epoch with a range check.
Why is my epoch off by 1,000 or 1,000,000? You likely mixed units (s vs ms vs µs). Verify length and documentation. Adjust by multiplying or dividing.