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.
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.
// Current Timestamp
1672531200
// ISO 8601
2023-01-01T00:00:00Z 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.
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.
// 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
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.
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.
-- 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.
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.
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.
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.
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.
JavaScript: Math.floor(Date.now()/1000). PHP: time(). Python: int(time.time()). MySQL: UNIX_TIMESTAMP().
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.
Yes. Pick a date and time, click Convert to Timestamp, and the tool shows the epoch value in seconds and milliseconds.
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.