Unix Timestamp Converter: Epoch & POSIX Time to Date

Convert Unix timestamps (epoch/POSIX time) to human-readable dates, or convert dates to Unix time. Supports seconds and milliseconds.

A Unix timestamp (also called epoch time or POSIX time) is the number of seconds since January 1, 1970 00:00:00 UTC. Enter a timestamp to convert it to a human-readable date, or enter a date string to get its Unix timestamp. This tool supports both seconds (10 digits, e.g., 1700000000) and milliseconds (13 digits, e.g., 1700000000000). All conversions run in your browser — nothing is uploaded.

Timestamp to date
Date string to timestamp

Unix timestamp format

Unix time (also called epoch time or POSIX time) counts the number of seconds since the Unix epoch: January 1, 1970 at 00:00:00 UTC. It's a universal way to represent time as a single number, independent of timezone.

10-digit seconds vs 13-digit milliseconds

  • Seconds (10 digits): Traditional Unix time, e.g., 1700000000 → November 14, 2023.
  • Milliseconds (13 digits): JavaScript and many modern APIs use milliseconds, e.g., 1700000000000.

JavaScript quirk: Date.now() returns milliseconds

In JavaScript, Date.now() returns milliseconds, not seconds. To get Unix seconds: Math.floor(Date.now() / 1000). The Date constructor also expects milliseconds: use new Date(seconds * 1000) when converting from Unix seconds.

ISO 8601 format

The ISO 8601 format (2023-11-14T22:13:20.000Z) is the standard human-readable representation. The trailing Zindicates UTC. Use toISOString() in JavaScript to convert a Date to this format.

How it works

  1. Timestamp to date: Enter a Unix timestamp and select whether it's in seconds or milliseconds. Click Convert to see the date in multiple formats (ISO 8601, UTC string, and your local timezone).
  2. Date string to timestamp: Enter a date string (ISO 8601 recommended, e.g., 2024-01-15T14:30:00Z) and click Convert to get the Unix timestamp in both seconds and milliseconds.
  3. Now button: Instantly fills the current time using Date.now().
  4. Use the sample button to try the converter with 1700000000 (seconds), which converts to November 14, 2023.

Get the current Unix timestamp

Get the current time as a Unix timestamp in various languages and environments.

JavaScript

// Seconds (10 digits, traditional Unix time)
const seconds = Math.floor(Date.now() / 1000);

// Milliseconds (13 digits, JavaScript native)
const milliseconds = Date.now();

Shell (Bash)

# GNU/Linux and macOS
date +%s

Python

import time
int(time.time())  # seconds since epoch

SQL

-- MySQL
SELECT UNIX_TIMESTAMP();

-- PostgreSQL
SELECT EXTRACT(EPOCH FROM NOW())::INTEGER;

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

Convert a date to a Unix timestamp

Convert a specific date and time to its Unix timestamp representation.

JavaScript

// From an ISO 8601 string (always include timezone for accuracy)
Math.floor(new Date('2024-01-01T00:00:00Z').getTime() / 1000);
// → 1704067200

// Current time in seconds
Math.floor(Date.now() / 1000);

Shell (Bash)

# GNU date (Linux)
date -d '2024-01-01 UTC' +%s
# → 1704067200

# macOS/BSD date (-u for UTC)
date -j -u -f '%Y-%m-%d %H:%M:%S' '2024-01-01 00:00:00' +%s

Python

from datetime import datetime, timezone
import calendar

# Using datetime with timezone
dt = datetime(2024, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
int(dt.timestamp())  # → 1704067200

# Using calendar.timegm for UTC tuples
calendar.timegm((2024, 1, 1, 0, 0, 0))  # → 1704067200

SQL

-- MySQL (assumes session time_zone = '+00:00')
SELECT UNIX_TIMESTAMP('2024-01-01 00:00:00');
-- → 1704067200

-- PostgreSQL (TIMESTAMPTZ with offset)
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '2024-01-01 00:00:00+00')::INTEGER;
-- → 1704067200

-- SQLite
SELECT strftime('%s', '2024-01-01 00:00:00');
-- → 1704067200

Convert Unix timestamp to date (JavaScript)

JavaScript's Date object works in milliseconds internally, while traditional Unix timestamps are in seconds.

From seconds: multiply by 1000

const date = new Date(1700000000 * 1000);

// UTC output (ISO 8601)
date.toISOString();  // "2023-11-14T22:13:20.000Z"

// Local time output (browser timezone)
date.toLocaleString();  // varies by timezone

Seconds vs milliseconds

The same number interpreted differently gives vastly different dates:

// 1700000000 as seconds → November 2023
new Date(1700000000 * 1000).toISOString();
// "2023-11-14T22:13:20.000Z"

// 1700000000 as milliseconds → January 1970
new Date(1700000000).toISOString();
// "1970-01-20T16:13:20.000Z"

Convert a Unix timestamp to a date in Python and Node

Convert on this page treats the number as seconds (default) or milliseconds and writes UTC ISO 8601 with Date#toISOString — 1700000000 seconds is 2023-11-14T22:13:20.000Z. Node Date is that same constructor. CPython datetime.fromtimestamp(..., tz=timezone.utc) is the UTC-aware API; Python 3.12 deprecates utcfromtimestamp in favor of it. Both write that same instant. Date-to-timestamp snippets stay in Convert a date to a Unix timestamp. Seconds vs milliseconds is in Unix Seconds vs Milliseconds: UTC vs Local.

Node.js with Date

Node's Date constructor expects milliseconds. Multiply Unix seconds by 1000, the same as this page's Seconds mode. toISOString() is the ISO row this page shows:

new Date(1700000000 * 1000).toISOString()
// "2023-11-14T22:13:20.000Z"

// Same digits as milliseconds (this page's Milliseconds mode)
new Date(1700000000).toISOString()
// "1970-01-20T16:13:20.000Z"

Python with datetime.fromtimestamp

CPython datetime.fromtimestamp reads POSIX seconds. Pass timezone.utc — a naive fromtimestamp is local time, not this page's UTC ISO row. isoformat(timespec='milliseconds') writes +00:00; this page writes Z. strftime with a Z suffix matches the ISO row for a whole-second timestamp:

from datetime import datetime, timezone

dt = datetime.fromtimestamp(1700000000, tz=timezone.utc)
# datetime.datetime(2023, 11, 14, 22, 13, 20, tzinfo=datetime.timezone.utc)

dt.strftime('%Y-%m-%dT%H:%M:%S.000Z')
# '2023-11-14T22:13:20.000Z'

datetime.fromtimestamp(1700000000 / 1000, tz=timezone.utc).strftime(
    '%Y-%m-%dT%H:%M:%S.000Z'
)
# '1970-01-20T16:13:20.000Z'

datetime.utcfromtimestamp is deprecated in Python 3.12 and returns a naive datetime. time.gmtime / time.strftime omit the .000 milliseconds this page writes. Empty input asks for a timestamp here; fromtimestamp(0) is 1970-01-01T00:00:00.000Z. Non-numeric strings fail here before Date. Fractional seconds (1700000000.5) work here, in Node, and in fromtimestamp. Instants outside the ECMAScript time value range fail here; CPython may still format them. Leap seconds are ignored.

Convert a Unix timestamp to a date in the shell

Convert on this page writes UTC ISO 8601. GNU date -d @SECONDS and macOS date -r SECONDS read POSIX seconds, not JavaScript milliseconds. Pass -u (or TZ=UTC) to match this page's ISO row; without it, date uses the local zone. There is no POSIX date flag that reads seconds-since-epoch — date +%s is the current time only (see Get the current Unix timestamp). These commands format one instant; they do not parse a pasted ISO string. Date-to-timestamp snippets stay in Convert a date to a Unix timestamp.

GNU date (Linux)

-d @1700000000 / --date=@1700000000 is seconds since the epoch. -u forces UTC. GNU -r is --reference (a file's mtime), not a timestamp:

date -u -d @1700000000 +%Y-%m-%dT%H:%M:%S.000Z
# 2023-11-14T22:13:20.000Z

# Same digits as milliseconds: divide by 1000 first
date -u -d @1700000 +%Y-%m-%dT%H:%M:%S.000Z
# 1970-01-20T16:13:20.000Z

macOS / BSD date

Apple date has no -d @. -r is seconds since the epoch. Homebrew coreutils installs gdate:

date -u -r 1700000000 +%Y-%m-%dT%H:%M:%S.000Z
# 2023-11-14T22:13:20.000Z

GNU date -d @1700000000000 treats that as seconds (year 55840), not this page's Milliseconds mode — divide 13-digit values by 1000 first. Invalid @notanumber prints date: invalid date. Empty input here asks for a timestamp. Fractional @1700000000.5 is 22:13:20.500Z in GNU date; this page also accepts that decimal. Windows PowerShell [DateTimeOffset]::FromUnixTimeSeconds(1700000000) is UTC; FromUnixTimeMilliseconds is the 13-digit clock. SQL FROM_UNIXTIME / to_timestamp stay in Unix timestamps in SQL.

Unix timestamps in SQL

SQL databases handle Unix timestamps differently. The term POSIX time is another name for Unix time.

MySQL

UNIX_TIMESTAMP() returns the current time as seconds since epoch.FROM_UNIXTIME() converts a timestamp back to a datetime.

SET time_zone = '+00:00';

-- Get current Unix timestamp
SELECT UNIX_TIMESTAMP();
-- 1728892800

-- Convert timestamp to datetime
SELECT FROM_UNIXTIME(1700000000);
-- '2023-11-14 22:13:20'

-- Convert datetime to timestamp
SELECT UNIX_TIMESTAMP('2024-01-01 00:00:00');
-- 1704067200

PostgreSQL

EXTRACT(EPOCH FROM ...) returns Unix seconds from a timestamp.to_timestamp() converts seconds back to a timestamp.

-- Get current Unix timestamp
SELECT EXTRACT(EPOCH FROM NOW())::BIGINT;
-- 1728892800

-- Convert timestamp to Unix seconds
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '2024-01-01 00:00:00+00');
-- 1704067200

-- Convert Unix seconds to timestamp (with TimeZone = 'UTC')
SELECT to_timestamp(1700000000);
-- 2023-11-14 22:13:20+00

Presto / Trino

Presto and Trino use to_unixtime() and from_unixtime() for Unix timestamp conversions.

-- Get current Unix timestamp
SELECT to_unixtime(NOW());
-- 1728892800.123

-- Convert timestamp to Unix seconds
SELECT to_unixtime(TIMESTAMP '2024-01-01 00:00:00 UTC');
-- 1704067200.0

-- Convert Unix seconds to timestamp
SELECT from_unixtime(1700000000);
-- 2023-11-14 22:13:20.000 UTC

SQLite

SQLite uses strftime('%s', ...) to get Unix seconds and datetime(..., 'unixepoch') to convert back.

-- Get current Unix timestamp
SELECT strftime('%s', 'now');
-- '1728892800'

-- Convert timestamp to datetime
SELECT datetime(1700000000, 'unixepoch');
-- '2023-11-14 22:13:20'

-- Convert datetime to timestamp
SELECT strftime('%s', '2024-01-01 00:00:00');
-- '1704067200'

FAQ

What is a Unix timestamp?
A Unix timestamp (also called epoch time or POSIX time) is the number of seconds that have elapsed since January 1, 1970 at 00:00:00 UTC. It is used universally in programming to represent points in time as a single number.
How do I convert a Unix timestamp to a date in JavaScript?
Multiply seconds by 1000 and pass to the Date constructor: new Date(timestamp * 1000). If your timestamp is already in milliseconds (13 digits), use new Date(timestamp) directly. The Date object gives you toISOString() for UTC or toLocaleString() for local time.
How do I convert a date to Unix timestamp (epoch) in JavaScript?
Use Math.floor(new Date("2026-01-01T00:00:00Z").getTime() / 1000) for seconds, or new Date("2026-01-01T00:00:00Z").getTime() for milliseconds. For the current time: Math.floor(Date.now() / 1000) gives seconds, Date.now() gives milliseconds.
How do I convert a date to Unix timestamp?
Enter any date string (like "2024-01-15" or "2024-01-15T14:30:00Z") in the "Date string to timestamp" section and click Convert. ISO 8601 format with timezone is recommended for accuracy.
How do I get the current Unix timestamp in Python?
Use int(time.time()) from the time module to get the current Unix timestamp in seconds. For a specific datetime, use datetime(2024, 1, 1, tzinfo=timezone.utc).timestamp() or calendar.timegm() for UTC tuples.
How do I get the Unix timestamp in a shell script?
Run date +%s to get the current Unix timestamp. To convert a specific date on GNU/Linux, use date -d '2024-01-01 UTC' +%s. On macOS, use date -j -u -f '%Y-%m-%d %H:%M:%S' '2024-01-01 00:00:00' +%s (the -u flag ensures UTC).
How do I convert a date to Unix timestamp in SQL?
In MySQL, use UNIX_TIMESTAMP('2024-01-01 00:00:00') (assumes session time_zone is UTC). In PostgreSQL, use EXTRACT(EPOCH FROM TIMESTAMPTZ '2024-01-01 00:00:00+00')::BIGINT. In SQLite, use strftime('%s', '2024-01-01').
Should I use seconds or milliseconds?
Traditional Unix time is in seconds (10 digits like 1700000000). JavaScript Date.now() and many APIs use milliseconds (13 digits like 1700000000000). This tool supports both — just select the correct unit before converting.
What is the difference between UTC and local time?
UTC is the universal reference time (no timezone offset). Local time is UTC adjusted for your timezone. A Unix timestamp always represents a UTC instant. When you display it, toISOString() shows UTC (ending in Z), while toLocaleString() converts to your browser timezone.
Is the result in UTC or local time?
The ISO 8601 output is always UTC (ending in Z). The "Local" row shows the time converted to your browser timezone. The tool displays your detected timezone for reference.
Why does my date parse incorrectly?
Date parsing depends on format: "2024-01-15" (date only) is parsed as UTC midnight. "2024-01-15T14:30:00" (no timezone) is parsed as local time. Always include a timezone (Z for UTC, or +00:00) for consistent results.
Does this account for leap seconds?
No. Unix time ignores leap seconds — it counts SI seconds since the epoch without adjustment. This is standard behavior for JavaScript Date and most programming languages.

Related