Epoch Time Converter

Convert Unix timestamps to human-readable dates and back. Live current epoch in seconds and milliseconds.

Current Unix Timestamp
— ms
Enter a timestamp above
Select a date and time above

Code Examples — Get Current Unix Timestamp

// Current Unix timestamp in JavaScript

// Milliseconds (13 digits)
const ms = Date.now();

// Seconds (10 digits)
const sec = Math.floor(Date.now() / 1000);

// Convert timestamp back to Date
const date = new Date(sec * 1000);       // seconds → ms
const iso  = date.toISOString();        // "2026-02-25T12:34:56.000Z"
const local = date.toLocaleString();    // local timezone string
import time
from datetime import datetime, timezone

# Current Unix timestamp (seconds)
ts_sec = int(time.time())

# Current Unix timestamp (milliseconds)
ts_ms  = int(time.time() * 1000)

# Convert timestamp back to UTC datetime
dt_utc = datetime.utcfromtimestamp(ts_sec)
print(dt_utc.strftime("%Y-%m-%d %H:%M:%S"))  # "2026-02-25 12:34:56"

# Timezone-aware (preferred in Python 3.2+)
dt_aware = datetime.fromtimestamp(ts_sec, tz=timezone.utc)
// Current Unix timestamp in PHP

// Seconds
$ts = time();

// Milliseconds
$ts_ms = (int)(microtime(true) * 1000);

// Convert timestamp to date string
$date = date('Y-m-d H:i:s', $ts);   // "2026-02-25 12:34:56" (local)
$utc  = gmdate('Y-m-d H:i:s', $ts);  // UTC

// Using DateTime
$dt = new DateTime('@' . $ts);       // always UTC
echo $dt->format('Y-m-d\TH:i:sZ');
package main

import (
    "fmt"
    "time"
)

func main() {
    now := time.Now()

    // Unix timestamp in seconds
    sec := now.Unix()

    // Unix timestamp in milliseconds
    ms := now.UnixMilli()

    // Convert back to time.Time
    t := time.Unix(sec, 0).UTC()
    fmt.Println(t.Format(time.RFC3339))   // "2026-02-25T12:34:56Z"

    fmt.Println(sec, ms)
}
use std::time::{SystemTime, UNIX_EPOCH};

fn main() {
    let now = SystemTime::now()
        .duration_since(UNIX_EPOCH)
        .expect("Time went backwards");

    // Unix timestamp in seconds
    let sec = now.as_secs();

    // Unix timestamp in milliseconds
    let ms  = now.as_millis();

    println!("Seconds: {}", sec);
    println!("Milliseconds: {}", ms);
    // Use the `chrono` crate to convert back to a DateTime
}
-- Current Unix timestamp in common databases

-- PostgreSQL
SELECT EXTRACT(EPOCH FROM NOW())::BIGINT;           -- seconds
SELECT EXTRACT(EPOCH FROM NOW()) * 1000;            -- milliseconds

-- MySQL / MariaDB
SELECT UNIX_TIMESTAMP();                              -- seconds
SELECT UNIX_TIMESTAMP() * 1000;                     -- milliseconds

-- SQL Server
SELECT DATEDIFF(SECOND, '1970-01-01', GETUTCDATE()); -- seconds

-- SQLite
SELECT strftime('%s', 'now');                       -- seconds

What Is an Epoch Timestamp?

An epoch timestamp — commonly called a Unix timestamp or POSIX time — is a single integer representing a point in time. It counts the number of seconds (or milliseconds, in many web environments) elapsed since the Unix epoch: January 1, 1970, 00:00:00 UTC. Because the timestamp is a plain number with no timezone or locale information attached, it is the most portable, unambiguous way to store or transmit a moment in time.

Every second, every device on Earth that is keeping accurate time will increment its Unix timestamp by exactly one, regardless of what timezone or locale it is configured to use. This makes timestamps ideal for databases, APIs, log files, and any system where two machines in different timezones need to agree on when something happened.

Seconds vs Milliseconds

The original Unix specification counts in whole seconds. The current Unix time in seconds is approximately 1.74 billion (in early 2026). JavaScript's Date.now() and many web APIs return milliseconds — a number roughly 1,000 times larger. If you receive a timestamp with 13 digits, it is almost certainly milliseconds. If it has 10 digits, it is seconds. This converter auto-detects which unit you entered based on magnitude.

When converting a seconds-based timestamp to a JavaScript Date, multiply by 1,000 first: new Date(timestamp * 1000). Forgetting this step is the most common source of epoch conversion bugs — you end up with a date in 1970 instead of the present.

Converting Timestamps in Common Languages

JavaScript (browser/Node.js): Math.floor(Date.now() / 1000) for the current Unix time in seconds. Convert back: new Date(ts * 1000).toISOString().

Python: import time; int(time.time()) for current seconds. Convert a timestamp: datetime.utcfromtimestamp(ts) from the datetime module.

PHP: time() returns current Unix time. Convert: date('Y-m-d H:i:s', $timestamp).

Go: time.Now().Unix() for seconds, time.Now().UnixMilli() for milliseconds.

Rust: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs().

SQL: UNIX_TIMESTAMP() in MySQL, EXTRACT(EPOCH FROM NOW()) in PostgreSQL.

The Year 2038 Problem

Systems that store Unix timestamps as 32-bit signed integers can represent a maximum value of 2,147,483,647 — which corresponds to January 19, 2038 at 03:14:07 UTC. After that moment, a 32-bit counter overflows to a large negative number, which most systems would interpret as a date in 1901. This is the Year 2038 problem (Y2K38), and while modern 64-bit systems are immune, embedded systems, legacy databases, and old filesystems remain at risk.

A 64-bit signed Unix timestamp can safely represent dates approximately 292 billion years in either direction from the epoch — well beyond any practical concern.

Frequently Asked Questions

What is an epoch timestamp?

An epoch (Unix) timestamp is the number of seconds elapsed since January 1, 1970, 00:00:00 UTC. It is timezone-independent and is the standard way to represent an exact moment in time across systems and programming languages.

How do I convert a Unix timestamp to a readable date?

In JavaScript: new Date(timestamp * 1000).toLocaleString() (multiply by 1000 if seconds). In Python: datetime.utcfromtimestamp(timestamp). Or paste the timestamp into the converter above for instant results in multiple formats.

What is the maximum Unix timestamp (Year 2038 problem)?

The maximum 32-bit signed integer Unix timestamp is 2,147,483,647, which equals January 19, 2038 at 03:14:07 UTC. Systems using 64-bit integers (all modern systems) are unaffected. Only older embedded or legacy systems using 32-bit signed storage are at risk.

How do I get the current Unix timestamp in JavaScript?

Math.floor(Date.now() / 1000) returns the current Unix time in seconds. Date.now() alone returns milliseconds. Both are equivalent — it just depends whether your downstream system expects seconds or milliseconds.

Why does the Unix epoch start on January 1, 1970?

Unix was developed at Bell Labs in the late 1960s and early 1970s. The team chose January 1, 1970 as a convenient, round starting point that predates the system itself, ensuring that all real-world timestamps are positive integers.

Related Developer Tools