Convert Unix epoch timestamps to dates and dates to timestamps. Auto-detects seconds, milliseconds, and microseconds.
Current Unix Timestamp (Live)
// Seconds timestamp const ts = Math.floor(Date.now() / 1000); // Milliseconds timestamp const tsMs = Date.now(); // Convert back new Date(ts * 1000).toISOString();
import time, datetime # Current timestamp ts = int(time.time()) # Convert back datetime.datetime.fromtimestamp(ts)
// Current timestamp
$ts = time();
// Convert back
date('Y-m-d H:i:s', $ts);import "time" // Current timestamp ts := time.Now().Unix() // Convert back time.Unix(ts, 0)
A Unix timestamp (also called epoch time or POSIX time) is the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC. This date is known as the Unix epoch. For example, the timestamp 1704067200 represents January 1, 2024, at midnight UTC. Timestamps are used in programming, databases, and APIs because they provide a timezone-independent way to represent time.
A seconds-based timestamp has 10 digits (e.g., 1704067200) and counts seconds since the epoch. A milliseconds-based timestamp has 13 digits (e.g., 1704067200000) and counts milliseconds, providing more precision. JavaScript's Date.now() returns milliseconds, while most Unix systems use seconds. This converter auto-detects the format based on digit count.
The Year 2038 problem occurs because many older systems store Unix timestamps as a 32-bit signed integer, which can only represent dates up to January 19, 2038, 03:14:07 UTC. After this point, the integer overflows and wraps around to a negative number, potentially causing system failures. Modern 64-bit systems have already solved this by using 64-bit integers, which can represent dates billions of years into the future.
In JavaScript, use Math.floor(Date.now() / 1000) for seconds or Date.now() for milliseconds. To convert a timestamp back to a date, use new Date(timestamp * 1000) if the timestamp is in seconds.
Unix timestamps are timezone-independent (always UTC), easy to store as a single integer, simple to compare (just compare numbers), and make date arithmetic straightforward — adding 86400 gives you exactly one day later. They eliminate ambiguity caused by different date formats across regions (DD/MM/YYYY vs MM/DD/YYYY).