Unix Timestamp Converter
Convert Unix timestamps to human-readable dates and vice versa. See the current epoch time live, with code examples in JavaScript, Python, PHP, Go, and MySQL.
How to use the Epoch Converter
Three steps to convert any Unix timestamp to a readable date.
Enter Your Timestamp
Type or paste a Unix timestamp into the Timestamp → Date input. 10 digits = seconds, 13 digits = milliseconds.
Choose Seconds or Milliseconds
Toggle the unit to match your timestamp. The tool converts instantly and shows local time, UTC, ISO 8601, and relative time.
Read or Copy the Result
Click any Copy button next to the output row you need. The button flashes green to confirm the copy.
Code examples
Working with Unix timestamps in JavaScript, Python, PHP, Go, and MySQL.
// Current timestamp in milliseconds
const nowMs = Date.now(); // e.g. 1704067200000
const nowSec = Math.floor(Date.now() / 1000); // e.g. 1704067200
// Timestamp (seconds) → Date object
const timestamp = 1704067200;
const date = new Date(timestamp * 1000);
console.log(date.toISOString()); // 2024-01-01T00:00:00.000Z
console.log(date.toLocaleDateString()); // 1/1/2024 (locale-dependent)
console.log(date.toUTCString()); // Mon, 01 Jan 2024 00:00:00 GMT
// Timestamp (milliseconds) → Date
const tsMs = 1704067200000;
const dateMs = new Date(tsMs);
console.log(dateMs.toISOString()); // 2024-01-01T00:00:00.000Z
// Date string → timestamp (seconds)
const ts = Math.floor(new Date('2024-01-01').getTime() / 1000);
console.log(ts); // 1704067200
import time
from datetime import datetime, timezone
# Current Unix timestamp (seconds, float)
now = time.time()
print(now) # e.g. 1704067200.123
# Current Unix timestamp (integer seconds)
now_int = int(time.time())
print(now_int) # 1704067200
# Timestamp → datetime (local timezone)
ts = 1704067200
dt_local = datetime.fromtimestamp(ts)
print(dt_local) # 2024-01-01 00:00:00 (local)
# Timestamp → datetime (UTC, timezone-aware)
dt_utc = datetime.fromtimestamp(ts, tz=timezone.utc)
print(dt_utc.isoformat()) # 2024-01-01T00:00:00+00:00
# datetime → timestamp
dt = datetime(2024, 1, 1, tzinfo=timezone.utc)
print(int(dt.timestamp())) # 1704067200
// Current Unix timestamp (seconds)
$now = time();
echo $now; // e.g. 1704067200
// Timestamp → formatted date string
$ts = 1704067200;
echo date('Y-m-d H:i:s', $ts); // 2024-01-01 00:00:00
echo date('D, d M Y H:i:s T', $ts); // Mon, 01 Jan 2024 00:00:00 UTC
echo date('c', $ts); // 2024-01-01T00:00:00+00:00
// Date string → timestamp
$ts2 = strtotime('2024-01-01 00:00:00 UTC');
echo $ts2; // 1704067200
// Using DateTime object (recommended)
$dt = new DateTime();
echo $dt->getTimestamp(); // current timestamp
$dt->setTimestamp(1704067200);
echo $dt->format('Y-m-d\TH:i:sP'); // ISO 8601
package main
import (
"fmt"
"time"
)
func main() {
// Current Unix timestamp
nowSec := time.Now().Unix() // seconds
nowMs := time.Now().UnixMilli() // milliseconds
fmt.Println(nowSec, nowMs)
// Timestamp (seconds) → time.Time
ts := int64(1704067200)
t := time.Unix(ts, 0)
fmt.Println(t.UTC().Format(time.RFC3339))
// 2024-01-01T00:00:00Z
// Timestamp (milliseconds) → time.Time
tsMs := int64(1704067200000)
tMs := time.UnixMilli(tsMs)
fmt.Println(tMs.UTC().Format(time.RFC3339))
// time.Time → Unix timestamp
parsed, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")
fmt.Println(parsed.Unix()) // 1704067200
fmt.Println(parsed.UnixMilli()) // 1704067200000
}
-- Current Unix timestamp (seconds)
SELECT UNIX_TIMESTAMP();
-- e.g. 1704067200
-- Timestamp → formatted date
SELECT FROM_UNIXTIME(1704067200);
-- 2024-01-01 00:00:00
SELECT FROM_UNIXTIME(1704067200, '%Y-%m-%d %H:%i:%S');
-- 2024-01-01 00:00:00
-- Date string → Unix timestamp
SELECT UNIX_TIMESTAMP('2024-01-01 00:00:00');
-- 1704067200
-- Store timestamps as BIGINT for 64-bit range
CREATE TABLE events (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
created_at BIGINT NOT NULL -- Unix seconds or ms
);
-- Alternatively use MySQL's DATETIME or TIMESTAMP types
-- TIMESTAMP stores as UTC and auto-converts; max: 2038-01-19
-- DATETIME stores literal value; max: 9999-12-31
What is a Unix timestamp?
A Unix timestamp (also called epoch time or POSIX time) is a single integer that represents the number of seconds elapsed since January 1, 1970, 00:00:00 UTC — a reference point known as the Unix epoch. Because it is a single absolute number independent of time zones and calendar systems, it is the universal standard for representing moments in time in programming and database systems.
Why do developers use epoch time?
Timestamps are easier to compare, sort, store, and transmit than formatted date strings. Subtracting two Unix timestamps gives the elapsed seconds between them. They fit in a 64-bit integer. There is no ambiguity about time zones, locale-specific date formats, or daylight saving time offsets. Most programming languages, databases, and APIs use Unix timestamps as their native time representation.
The Y2K38 problem
Many older 32-bit systems stored Unix timestamps as a signed 32-bit integer, which holds values up to 2,147,483,647. This limit is reached on January 19, 2038 at 03:14:07 UTC. At that moment, a 32-bit integer overflows and wraps to a large negative number (representing December 13, 1901), which could cause widespread failures in legacy systems — similar in concept to the Y2K bug. Modern 64-bit systems using int64 timestamps can represent dates billions of years into the future and past, so the problem only affects old 32-bit code and firmware.
Frequently asked questions
Everything you need to know about Unix timestamps and epoch time.
What is a Unix timestamp?
What is the difference between seconds and milliseconds timestamps?
1704067200). A milliseconds timestamp is 13 digits (e.g. 1704067200000) and offers sub-second precision. JavaScript's Date.now() and Java return milliseconds; Python's time.time() and Unix/Linux system calls return seconds. When in doubt, divide by 1000 if you have 13 digits.
What is the Unix epoch (time zero)?
0. This reference date was chosen by early Unix developers in the 1970s. All Unix timestamps are a positive or negative offset in seconds from this point. Negative timestamps represent dates before 1970.
What is the Y2K38 (2038) problem?
2,147,483,647 — corresponding to January 19, 2038 at 03:14:07 UTC. After that moment, the integer overflows to a negative value, causing date calculations to break catastrophically. Modern 64-bit systems are immune because int64 can represent dates ~292 billion years into the future.
How do I get the current timestamp in JavaScript?
Date.now() to get the current time in milliseconds. For seconds, use Math.floor(Date.now() / 1000). Alternatively, +new Date() and new Date().getTime() also return milliseconds. In Node.js, you can also use process.hrtime.bigint() for nanosecond precision.
Why do some timestamps have 13 digits?
Date.now() and Java's System.currentTimeMillis() both return milliseconds by default, which is why 13-digit timestamps are very common in web and mobile applications. If you see a 13-digit number, divide by 1000 to get the equivalent seconds timestamp.
More developer tools
Free, browser-based tools for everyday developer tasks.
Base64 Encoder
Encode and decode Base64 strings with Unicode support.
Try it →JSON Formatter
Prettify, validate, and minify JSON instantly.
Try it →URL Encoder
Encode and decode URL components and query strings.
Try it →Password Generator
Generate strong, random passwords with custom rules.
Try it →HTML Entities
Encode and decode HTML special characters and entities.
Try it →