Epoch Converter

Convert Unix timestamps to dates and back — seconds, milliseconds, any timezone

Current Unix Time
seconds
milliseconds
Timestamp → Date
Date → Timestamp

Epoch in Code

JavaScript

// Current timestamp
Math.floor(Date.now() / 1000) // seconds
Date.now()                    // ms

// Timestamp to Date
new Date(1717500000 * 1000)
new Date(1717500000000)       // ms

// Date to timestamp
Math.floor(new Date('2024-06-04').getTime() / 1000)

Python

import datetime, time

# Current timestamp
int(time.time())
time.time()           # float seconds

# Timestamp to datetime
datetime.datetime.fromtimestamp(1717500000)
datetime.datetime.utcfromtimestamp(1717500000)

# Date to timestamp
datetime.datetime(2024,6,4).timestamp()

SQL

-- PostgreSQL
SELECT to_timestamp(1717500000);
SELECT EXTRACT(EPOCH FROM NOW());

-- MySQL
SELECT FROM_UNIXTIME(1717500000);
SELECT UNIX_TIMESTAMP(NOW());

-- SQLite
SELECT datetime(1717500000, 'unixepoch');
SELECT strftime('%s', 'now');

Go / PHP / Java

// Go
time.Unix(1717500000, 0)
time.Now().Unix()

// PHP
date('Y-m-d', 1717500000);
strtotime('2024-06-04');

// Java
Instant.ofEpochSecond(1717500000L)
Instant.now().getEpochSecond()

Frequently Asked Questions

A Unix timestamp is the number of seconds that have elapsed since the Unix epoch: January 1, 1970, 00:00:00 UTC. It is a universal, timezone-independent way to represent any moment in time. The current timestamp is roughly 1.7 billion seconds. Timestamps are used in virtually every programming language, database, API, and log file because they avoid all ambiguity about timezones, date formats, and locale differences.

Unix timestamps traditionally measure seconds (10 digits, e.g. 1717500000). JavaScript's Date.now() returns milliseconds (13 digits, e.g. 1717500000000). This tool auto-detects based on the number of digits: 10 digits = seconds, 13 digits = milliseconds. If your timestamp is 13 digits, divide by 1000 to get seconds.

The "Year 2038 problem" affects systems that store Unix timestamps as a 32-bit signed integer. The maximum value is 2,147,483,647, which corresponds to January 19, 2038, 03:14:07 UTC. After that, the value overflows to a negative number. Modern 64-bit systems are not affected — a 64-bit timestamp can represent dates up to year 292 billion. JavaScript uses 64-bit floats and is safe. The issue mainly affects legacy C code and old database schemas.

January 1, 1970 was chosen as the epoch when Unix was developed at Bell Labs in the early 1970s. It was a recent, round date that made calculations convenient. The choice was somewhat arbitrary — the important thing was having a single, universally agreed starting point. That date is now permanently embedded in virtually every computer system on the planet.

For seconds: new Date(timestamp * 1000). For milliseconds: new Date(timestamp). To get the current timestamp in seconds: Math.floor(Date.now() / 1000). To convert a date string to timestamp: Math.floor(new Date('2024-06-04').getTime() / 1000).

Related Tools

Beware milliseconds vs seconds

In 2026, the most common copy/paste bug is still mixing Unix seconds with JavaScript-style milliseconds. A 10-digit value like 1735689600 is seconds; a 13-digit value like 1735689600000 is milliseconds. If a converter shows a date in 1970 or thousands of years in the future, you probably used the wrong unit. Before debugging time zones, first count the digits and divide or multiply by 1000 as needed. This also matters when moving timestamps between browser code, APIs, SQL, and observability tools.