Convert epoch seconds/milliseconds to human-readable dates—and back. Private by design (100% client-side).
About UNIX / Epoch Time
A UNIX timestamp (often called epoch time) is a single number that counts how much time
has passed since the Unix Epoch: 1970-01-01T00:00:00Z (UTC). It’s widely used in logs,
databases, and APIs because it’s compact, sortable, and timezone-agnostic.
Quick facts
- Seconds vs milliseconds vs nanoseconds:
- 10 digits → seconds (e.g.,
1700000000)
- 13 digits → milliseconds (e.g.,
1700000000000)
- 16 digits → microseconds (e.g.,
1700000000000000)
- 19 digits → nanoseconds (commonly from high-precision systems)
- Timezone-agnostic: the number represents an absolute moment; only its display changes with timezone/DST.
- Negative values represent dates before 1970-01-01 (e.g.,
-31536000 → 1969-01-01T00:00:00Z).
- Y2038 limit (32-bit seconds):
2147483647 → 2038-01-19T03:14:07Z. Modern systems use 64-bit and don’t suffer this limit.
Common examples
| Meaning | Seconds | Milliseconds | UTC (ISO-8601) |
| Epoch start |
0 |
0 |
1970-01-01T00:00:00Z |
| One billion seconds |
1000000000 |
1000000000000 |
2001-09-09T01:46:40Z |
| 2038 boundary (32-bit) |
2147483647 |
2147483647000 |
2038-01-19T03:14:07Z |
| Example current-era |
1600000000 |
1600000000000 |
2020-09-13T12:26:40Z |
Time zones & DST
- A timestamp is stored in UTC. When you view it in “Europe/London” or “America/New_York,” only the rendered string changes.
- DST jumps don’t change the underlying timestamp; they change how local time is displayed.
- For unambiguous strings, prefer ISO-8601 like
2025-03-01T10:30:00Z or with an offset (e.g., +01:00).
Parsing tips
- Browsers interpret a date string without a timezone in the user’s local timezone:
2025-03-01 10:30:00 → local time
2025-03-01T10:30:00Z → UTC (the trailing Z means Zulu/UTC)
2025-03-01T10:30:00+05:30 → UTC+5:30
- If you paste a 10-digit number (seconds) but expect milliseconds, multiply by 1000.
- If you paste a 19-digit value (nanoseconds), divide by
1,000,000 to get milliseconds.
When to use which unit?
- Seconds: many back-end APIs, databases, shell tools.
- Milliseconds: JavaScript
Date, browsers, most front-end code.
- Nanoseconds: high-precision logs/telemetry; convert to ms for JS
Date.
Epoch time by language (quick recipes)
Copy–paste friendly snippets for common tasks: get current epoch, convert a human date → epoch, and convert epoch → date.
JavaScript (Browser & Node)
// current epoch
const s = Math.floor(Date.now() / 1000); // seconds
const ms = Date.now(); // milliseconds
// date → epoch
const dt = new Date("2025-03-01T10:30:00Z");
const epochSeconds = Math.floor(dt.getTime() / 1000);
// epoch → date
const d1 = new Date(1700000000 * 1000); // seconds → ms
const d2 = new Date(1700000000000); // ms
Python
import time, datetime, calendar
# current epoch
sec = time.time() # float seconds
ms = round(time.time()*1000)
# date → epoch (UTC)
dt = datetime.datetime(2025, 3, 1, 10, 30, tzinfo=datetime.timezone.utc)
epoch_seconds = int(dt.timestamp())
# epoch → date (UTC)
dt2 = datetime.datetime.fromtimestamp(1700000000, tz=datetime.timezone.utc)
Java
import java.time.*;
long sec = Instant.now().getEpochSecond(); // current epoch (s)
long ms = Instant.now().toEpochMilli(); // current epoch (ms)
// date → epoch
Instant ins = Instant.parse("2025-03-01T10:30:00Z");
long epochSeconds = ins.getEpochSecond();
// epoch → date
Instant ins2 = Instant.ofEpochSecond(1700000000);
ZonedDateTime zdt = ins2.atZone(ZoneId.of("UTC"));
C# (.NET)
using System;
long sec = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
long ms = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
// date → epoch
var dto = new DateTimeOffset(2025, 3, 1, 10, 30, 0, TimeSpan.Zero);
long epochSeconds = dto.ToUnixTimeSeconds();
// epoch → date
var dto2 = DateTimeOffset.FromUnixTimeSeconds(1700000000); // UTC
Go
package main
import ("fmt"; "time")
func main() {
sec := time.Now().Unix() // seconds
ms := time.Now().UnixMilli() // milliseconds
// date → epoch (UTC)
t, _ := time.Parse(time.RFC3339, "2025-03-01T10:30:00Z")
fmt.Println(t.Unix())
// epoch → date
t2 := time.Unix(1700000000, 0).UTC()
fmt.Println(t2.Format(time.RFC3339))
}
PHP
// current epoch
$sec = time(); // seconds
$ms = round(microtime(true)*1000);
// date → epoch (UTC recommended)
$dt = new DateTime("2025-03-01T10:30:00Z");
$epoch = $dt->getTimestamp();
// epoch → date
$dt2 = (new DateTime())->setTimestamp(1700000000)->setTimezone(new DateTimeZone("UTC"));
echo $dt2->format(DATE_RFC3339);
Ruby
# current epoch
s = Time.now.to_i # seconds
ms = (Time.now.to_f*1000).to_i
# date → epoch (UTC)
t = Time.utc(2025,3,1,10,30,0)
s2 = t.to_i
# epoch → date
t2 = Time.at(1700000000).utc
Rust
use std::time::{SystemTime, UNIX_EPOCH, Duration};
// current epoch
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
let sec = now.as_secs();
let ms = now.as_millis();
// epoch → date (example with chrono)
use chrono::{DateTime, Utc, TimeZone};
let d: DateTime<Utc> = Utc.timestamp_opt(1_700_000_000, 0).unwrap();
Kotlin
import java.time.Instant
import java.time.ZoneId
val sec = Instant.now().epochSecond
val ms = Instant.now().toEpochMilli()
// date → epoch
val ins = Instant.parse("2025-03-01T10:30:00Z")
val epochSeconds = ins.epochSecond
// epoch → date
val zdt = Instant.ofEpochSecond(1700000000).atZone(ZoneId.of("UTC"))
Swift
import Foundation
let sec = Int(Date().timeIntervalSince1970) // seconds
let ms = Int(Date().timeIntervalSince1970 * 1000)
// date → epoch (ISO8601)
let iso = ISO8601DateFormatter().date(from: "2025-03-01T10:30:00Z")!
let epoch = Int(iso.timeIntervalSince1970)
// epoch → date
let d = Date(timeIntervalSince1970: 1700000000)
C++ (C++11+)
#include <chrono>
using namespace std::chrono;
// current epoch
auto now = system_clock::now();
auto sec = duration_cast<seconds>(now.time_since_epoch()).count();
auto ms = duration_cast<milliseconds>(now.time_since_epoch()).count();
// epoch → time_point
auto tp = system_clock::time_point{seconds{1700000000}};
Bash / Unix shell
# current epoch
date +%s # seconds
python3 - <<'PY'\nimport time; print(round(time.time()*1000))\nPY # ms fallback
# date → epoch (UTC)
date -u -d "2025-03-01 10:30:00" +%s
# epoch → date (local or -u for UTC)
date -d @1700000000
PowerShell
# current epoch
$sec = [int][double]::Parse((Get-Date (Get-Date).ToUniversalTime() -UFormat %s))
$ms = [int]([DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds())
# epoch → date
[DateTimeOffset]::FromUnixTimeSeconds(1700000000).UtcDateTime
PostgreSQL
-- current epoch (seconds)
SELECT EXTRACT(EPOCH FROM NOW());
-- date → epoch (UTC)
SELECT EXTRACT(EPOCH FROM TIMESTAMP '2025-03-01 10:30:00+00');
-- epoch → timestamp
SELECT TO_TIMESTAMP(1700000000) AT TIME ZONE 'UTC';
MySQL / MariaDB
-- current epoch
SELECT UNIX_TIMESTAMP();
-- date → epoch (assumes UTC string if suffixed with 'Z')
SELECT UNIX_TIMESTAMP('2025-03-01 10:30:00');
-- epoch → datetime
SELECT FROM_UNIXTIME(1700000000);
Tip: prefer ISO-8601 strings (e.g., 2025-03-01T10:30:00Z) for unambiguous UTC. If an API expects seconds but you have milliseconds, divide by 1000 (and multiply for the reverse).