Learn to convert epoch date (Unix timestamps) to readable dates across JavaScript, Python, SQL, Excel, and command line. Includes step-by-step methods, common pitfalls, best practices, and expert tips.
Epoch time (also called Unix time or POSIX time) is how computers track time: the seconds since 00:00:00 UTC on 1 January 1970. You’ll see it in logs, APIs, and databases. If you work with data, you’ll need to convert epoch date to a human-friendly format—and back—without breaking time zones or milliseconds.
Here’s exactly how to do it, fast and correctly.
Quick answer (Featured Snippet): To convert epoch date, first know whether the value is in seconds or milliseconds. For seconds, use a language’s fromtimestamp() or equivalent (e.g., new Date(epoch * 1000) in JavaScript). For milliseconds, pass the value directly (e.g., new Date(ms)). Always set or format in UTC or a known time zone, and output ISO 8601 when sharing.
AI Overview: Converting an epoch date means transforming a Unix timestamp (seconds or milliseconds since 1970-01-01T00:00:00Z) into a readable date-time and vice versa. Identify the unit (seconds vs. milliseconds). Use built-in functions: JavaScript new Date(), Python datetime.fromtimestamp(), SQL to_timestamp()/FROM_UNIXTIME(), Excel/Sheets conversion plus 25569 offset. Always handle UTC, time zones, and daylight saving carefully. Prefer ISO 8601 (e.g., 2026-08-13T12:34:56Z) for consistent sharing.
When people say “convert epoch date,” they mean translating a Unix timestamp into a readable date-time or the reverse.
Converting correctly requires:
Tip: Document the unit in code comments and API contracts.
date -u -d @1699980000
date -d @1699980000
ms=1699980000000; date -u -d @$(($ms/1000))
date +%s
date -u -d @1699980000 +"%Y-%m-%dT%H:%M:%SZ"
Note: BSD/macOS date uses slightly different flags. Portable approach:
python3 - <<'PY'
import datetime,sys
print(datetime.datetime.utcfromtimestamp(1699980000).isoformat()+"Z")
PY
$epoch=1699980000
(Get-Date 01/01/1970 -UFormat %s) | Out-Null
[DateTimeOffset]::FromUnixTimeSeconds($epoch).UtcDateTime
[DateTimeOffset]::FromUnixTimeMilliseconds(1699980000000).UtcDateTime
[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
const s = 1699980000;
const d = new Date(s * 1000); // local time zone by default
const ms = 1699980000000;
const d = new Date(ms);
const iso = d.toISOString(); // e.g., 2026-11-14T10:00:00.000Z
const epochMs = d.getTime(); // milliseconds
const epochS = Math.floor(d.getTime()/1000); // seconds
const fmt = new Intl.DateTimeFormat('en-US', {
timeZone: 'America/Los_Angeles',
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit'
}).format(d);
import datetime as dt
s = 1699980000
print(dt.datetime.fromtimestamp(s)) # local
print(dt.datetime.utcfromtimestamp(s)) # UTC (naive)
print(dt.datetime.fromtimestamp(s, dt.timezone.utc)) # aware UTC
ms = 1699980000000
print(dt.datetime.fromtimestamp(ms/1000, dt.timezone.utc))
now = dt.datetime.now(dt.timezone.utc)
epoch_s = int(now.timestamp())
epoch_ms = int(now.timestamp() * 1000)
now.isoformat().replace('+00:00','Z')
long s = 1699980000L;
java.time.Instant instant = java.time.Instant.ofEpochSecond(s);
java.time.ZonedDateTime utc = instant.atZone(java.time.ZoneOffset.UTC);
long ms = 1699980000000L;
Instant instant = Instant.ofEpochMilli(ms);
String iso = java.time.format.DateTimeFormatter.ISO_INSTANT.format(instant);
long nowS = Instant.now().getEpochSecond();
long nowMs = Instant.now().toEpochMilli();
-- seconds to timestamp (UTC by default)
SELECT to_timestamp(1699980000) AT TIME ZONE 'UTC';
-- milliseconds
SELECT to_timestamp(1699980000000 / 1000.0) AT TIME ZONE 'UTC';
-- timestamp to epoch seconds
SELECT EXTRACT(EPOCH FROM TIMESTAMP '2026-11-14 10:00:00+00');
-- seconds to datetime
SELECT FROM_UNIXTIME(1699980000);
-- milliseconds to datetime
SELECT FROM_UNIXTIME(1699980000000/1000);
-- datetime to epoch seconds
SELECT UNIX_TIMESTAMP('2026-11-14 10:00:00');
-- seconds to timestamp
SELECT TIMESTAMP_SECONDS(1699980000);
-- milliseconds to timestamp
SELECT TIMESTAMP_MILLIS(1699980000000);
-- timestamp to epoch
SELECT UNIX_SECONDS(TIMESTAMP '2026-11-14 10:00:00+00');
Seconds to Excel date (in days):
= (A2 / 86400) + 25569
Where A2 has epoch seconds. Format the cell as date/time.
Milliseconds:
= (A2 / 1000 / 86400) + 25569
Convert Excel date back to epoch seconds:
= (A2 - 25569) * 86400
Note: Excel applies your local time zone when formatting. For UTC-only, keep as value and label as UTC, or use Power Query/Office Scripts.
Example (Python zone conversion):
from zoneinfo import ZoneInfo
import datetime as dt
s = 1699980000
utc = dt.datetime.fromtimestamp(s, dt.timezone.utc)
pst = utc.astimezone(ZoneInfo('America/Los_Angeles'))
| Method/Tool | Input Unit | Output | Pros | Cons | Best For |
|---|---|---|---|---|---|
| ZenixTools Epoch Converter | s or ms | ISO, local/UTC | Fast, no code | Manual step | Quick checks |
| Linux date | s (ms via math) | Any format | Ubiquitous, scriptable | BSD/macOS flags differ | DevOps, scripts |
| PowerShell | s or ms | UTC/local DateTime | Native on Windows | Verbose | Windows admins |
| JavaScript Date | s (×1000) or ms | ISO/local | Frontend/native | Time zone surprises | Web apps |
| Python datetime | s or ms/1000 | Aware UTC | Precise, clear | Zone handling needs care | Data/ETL |
To convert epoch date reliably, always confirm the unit, work in UTC, and output ISO 8601. Use built-in functions in your language, or a quick utility like ZenixTools for instant checks. Handle time zones intentionally, test around DST, and document your choices. With these habits, your timestamps will be accurate, portable, and easy to debug.
Need a fast, correct conversion? Paste your timestamp into the ZenixTools Epoch Converter. Toggle seconds or milliseconds, switch zones, and copy an ISO 8601 string in seconds. Stop guessing; ship accurate time data today.
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.
| Java java.time |
| s or ms |
| Instant/Zoned |
| Strong typing |
| Boilerplate |
| Enterprise apps |
| PostgreSQL/MySQL | s or ms/1000 | timestamp | In-DB convert | Vendor nuances | DB queries |
| Excel/Sheets | s or ms | Formatted cell | Analysts | TZ confusion | Quick analysis |