Unix Timestamp Converter

Convert a Unix timestamp to a readable date, or a date back to a timestamp. The result shows UTC and your local time side by side, because mixing the two up is how a log ends up eight hours out of order.

Current Unix Time Loading...
Timestamp to Date
GMT / UTC
-
Your Local Time
-
ISO 8601
-
Relative
-
Date to Timestamp
Seconds (Unix Timestamp)
Milliseconds

1 Epoch time counts seconds from 1970

A Unix timestamp (or epoch time) is the number of seconds since January 1, 1970 (00:00:00 UTC), not counting leap seconds. The same number means the same instant in every time zone. For example, 1767225600 is 2026-01-01 00:00:00 UTC.

2 Unix Timestamp Converter example

Timestamp Formats

1
2
3
4
5
// Current Timestamp
1672531200

// ISO 8601
2023-01-01T00:00:00Z

3 What Unix Timestamp Converter is for

Reading logs

Server logs and database rows often store epoch seconds. Converting one to local time tells you whether the incident happened at 03:00 or 11:00.

Seconds or milliseconds

A date in 1970 or in the year 55000 means the unit is wrong. JavaScript works in milliseconds and most other systems in seconds. The converter reads 12 or more digits as milliseconds and fewer as seconds.

How to use the Unix Timestamp Converter tool

  1. The header shows the current Unix time in seconds, updating every second. Click Refresh if the counter stopped while the tab was in the background.
  2. Type a timestamp into Enter Timestamp and click Convert to Date, or press Enter. The converter reads 12 or more digits as milliseconds and fewer as seconds.
  3. Read the results: GMT / UTC, Your Local Time with its offset, ISO 8601, and a Relative line such as "2 years ago". Each row has a Copy button.
  4. Click Set to Now to fill the field with the current second.
  5. To go the other way, pick a date and time in the date field and click Convert to Timestamp. The Seconds and Milliseconds boxes fill in, and each can be copied.

How to convert a Unix timestamp to a date in JavaScript, PHP, Python and SQL

JavaScript / Node.js

// Current Unix timestamp in seconds (Date.now() is milliseconds)
const now = Math.floor(Date.now() / 1000);
console.log(now);

// Timestamp to date: multiply seconds by 1000
const ts = 1703514600;
const d = new Date(ts * 1000);
console.log(d.toISOString());   // 2023-12-25T14:30:00.000Z
console.log(d.toLocaleString()); // in the machine's local zone

// Accept either seconds or milliseconds
function fromUnix(value) {
  const n = Number(value);
  return new Date(String(value).length >= 12 ? n : n * 1000);
}
console.log(fromUnix("1703514600000").toISOString());

// Date to timestamp
console.log(Math.floor(new Date("2023-12-25T14:30:00Z").getTime() / 1000)); // 1703514600

PHP

<?php
echo time(), PHP_EOL;                       // current timestamp in seconds

$ts = 1703514600;
echo gmdate("Y-m-d H:i:s", $ts), PHP_EOL;  // 2023-12-25 14:30:00 (UTC)
echo date("c", $ts), PHP_EOL;              // ISO 8601 in the server's default zone

// Object style with an explicit zone
$d = (new DateTimeImmutable("@$ts"))->setTimezone(new DateTimeZone("Europe/Berlin"));
echo $d->format("D, d M Y H:i:s T"), PHP_EOL;

// Date string to timestamp
echo strtotime("2023-12-25 14:30:00 UTC"), PHP_EOL; // 1703514600
echo (new DateTime("2023-12-25T14:30:00Z"))->getTimestamp(), PHP_EOL;

date() uses date.timezone from php.ini, while gmdate() is always UTC. Set the zone explicitly in production.

Python

import time
from datetime import datetime, timezone

print(int(time.time()))  # current timestamp in seconds

ts = 1703514600

# Always pass tz; a naive fromtimestamp() uses the machine's local zone
d = datetime.fromtimestamp(ts, tz=timezone.utc)
print(d.isoformat())                    # 2023-12-25T14:30:00+00:00
print(d.strftime("%a, %d %b %Y %H:%M:%S %Z"))

# Milliseconds from JavaScript: divide first
print(datetime.fromtimestamp(1703514600000 / 1000, tz=timezone.utc))

# Date to timestamp
dt = datetime(2023, 12, 25, 14, 30, tzinfo=timezone.utc)
print(int(dt.timestamp()))              # 1703514600

datetime.utcfromtimestamp() is deprecated since Python 3.12. Use fromtimestamp(ts, tz=timezone.utc) instead.

SQL (MySQL and PostgreSQL)

-- MySQL
SELECT UNIX_TIMESTAMP();                           -- current time in seconds
SELECT FROM_UNIXTIME(1703514600);                  -- 2023-12-25 14:30:00 (session zone)
SELECT FROM_UNIXTIME(1703514600, '%Y-%m-%dT%H:%i:%sZ');
SELECT UNIX_TIMESTAMP('2023-12-25 14:30:00');      -- date to timestamp

-- PostgreSQL
SELECT EXTRACT(EPOCH FROM NOW())::bigint;          -- current time in seconds
SELECT TO_TIMESTAMP(1703514600);                   -- 2023-12-25 14:30:00+00
SELECT TO_TIMESTAMP(1703514600) AT TIME ZONE 'UTC';
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '2023-12-25 14:30:00+00')::bigint;

This snippet is not run on this page. MySQL's FROM_UNIXTIME() follows the session time_zone, so set it to '+00:00' for stable output.

Common errors and how to fix them

The date is in 1970 or in the year 55000
Seconds and milliseconds were mixed up. new Date(1703514600) is 20 days after the epoch, and fromtimestamp(1703514600000) is far in the future. Multiply or divide by 1000 so the value has 10 digits for seconds or 13 for milliseconds.
Same timestamp shows a different hour on two machines
The timestamp is fine; the display zone differs. A Unix timestamp is always UTC, so format it with an explicit zone, such as toISOString(), gmdate() or tz=timezone.utc, when you need a fixed result.
Timestamp stored as a negative number or wraps after 2038-01-19
The column or variable is a signed 32-bit integer, which overflows at 2147483647. Use BIGINT in the database and 64-bit integers in code. PHP and Node.js on 64-bit systems are already safe.
Date to timestamp returns a value that is off by exactly my UTC offset
The date string had no zone, so it was parsed as local time. Append Z or +00:00, or build the datetime with tzinfo=timezone.utc, before converting.
OverflowError or RangeError: Invalid time value for a very large timestamp
You passed milliseconds where seconds were expected, or a value outside the language's supported range. JavaScript Dates reach about 270,000 years either side of 1970.

Good to know

Unix time is seconds since 1970-01-01T00:00:00Z, and it ignores leap seconds: every day is exactly 86400 seconds. When a leap second is inserted, the clock repeats or smears a second instead of counting to 86401. The arithmetic stays simple, at the cost of physical accuracy.

Keep integers in the database and in APIs, and convert to ISO 8601 at the edges. An integer has no format or zone to get wrong, and it sorts correctly. Never store a local-time string without its offset.

Specifications and references

This tool follows the specifications below. Read them when you need the exact normative wording, for example to settle an edge case between two implementations.

Guides and tutorials

Frequently Asked Questions

What is a Unix timestamp?

The number of seconds since 1 January 1970 00:00:00 UTC, the Unix epoch. The same number means the same instant in every time zone, so it is easy to store, sort and compare. For example, 1767225600 is 1 January 2026 at midnight UTC.

Seconds or milliseconds?

Unix tools and most databases use seconds (10 digits today). JavaScript's Date.now() uses milliseconds (13 digits). The converter reads 12 or more digits as milliseconds and fewer as seconds.

How do I get the current timestamp in code?

JavaScript: Math.floor(Date.now()/1000). PHP: time(). Python: int(time.time()). MySQL: UNIX_TIMESTAMP().

What happens in 2038?

A signed 32-bit timestamp overflows at 03:14:07 UTC on 19 January 2038, when it passes 2147483647. Modern systems use 64-bit integers, so check that your database columns and languages do too.

Can I convert a date back to a timestamp?

Yes. Pick a date and time, click Convert to Timestamp, and the tool shows the epoch value in seconds and milliseconds.

Related

The date format converter handles named formats rather than epoch seconds. If the timestamp came out of a scheduled job, the cron generator explains the schedule.

More Date & Time Tools

Browse all date & time tools

Copied to clipboard!