Get the current Unix timestamp in code
# Shell (Linux, macOS)
date +%s
// JavaScript: milliseconds, then seconds
Date.now()
Math.floor(Date.now() / 1000)
# Python
import time; int(time.time())
// PHP
time();
-- MySQL / PostgreSQL
SELECT UNIX_TIMESTAMP();
SELECT EXTRACT(EPOCH FROM now());
Convert a timestamp to a date in code
// JavaScript (expects milliseconds)
new Date(1767225600 * 1000).toISOString()
# Python
from datetime import datetime, timezone
datetime.fromtimestamp(1767225600, tz=timezone.utc)
// PHP
date('Y-m-d H:i:s', 1767225600);
-- MySQL / PostgreSQL
SELECT FROM_UNIXTIME(1767225600);
SELECT to_timestamp(1767225600);
All of these give 1 January 2026, 00:00 UTC. The most common bug is passing seconds to something that expects milliseconds, which gives a date in January 1970.
Unix time in Excel and Google Sheets
Spreadsheets count days from 1900, not seconds from 1970. To turn a Unix timestamp in A1 into a date, use =A1/86400 + DATE(1970,1,1) and format the cell as a date and time. For milliseconds, divide by 86,400,000 instead. To go the other way, use =(A1 - DATE(1970,1,1)) * 86400. The result is in UTC, so add or subtract hours for your time zone.
Useful timestamps to recognise
- 0: 1 January 1970, 00:00:00 UTC, the Unix epoch.
- 1,000,000,000: 9 September 2001, 01:46:40 UTC.
- 1,767,225,600: 1 January 2026, 00:00 UTC.
- 2,000,000,000: 18 May 2033, 03:33:20 UTC.
- 2,147,483,647: 19 January 2038, 03:14:07 UTC, the largest signed 32-bit value.
A 10-digit number that starts with 17 is almost certainly a timestamp in seconds from the mid-2020s.
Epoch, POSIX time and UTC timestamps
Epoch time, Unix time and POSIX time all mean the same count of seconds since 1970-01-01 00:00 UTC. A “UTC timestamp” usually means the same thing, or an ISO 8601 string ending in Z. Unix time ignores leap seconds, so every day is exactly 86,400 seconds long, which keeps date maths simple.