Convert a Unix timestamp to a human-readable date and time.
Date and time (UTC)
Date → Unix
Convert a human-readable date and time to a Unix timestamp.
Unix timestamp (seconds)
What is Unix time?
Unix time, also called epoch time or a Unix timestamp, counts the seconds since 1 January 1970 at 00:00:00 UTC. It is common in APIs, database records, log files and software.
Unix time is independent of your local time zone. The same instant can display differently in different places. Some systems store milliseconds, microseconds or nanoseconds instead of seconds; selecting the correct precision prevents incorrect dates.
USEFUL REFERENCES
Unix time in Python
import datetime
now = int(datetime.datetime.now(datetime.timezone.utc).timestamp())
date = datetime.datetime.fromtimestamp(now, datetime.timezone.utc)
Unix time in C#
long seconds = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
DateTimeOffset dt = DateTimeOffset.FromUnixTimeSeconds(seconds);
Unix time in JavaScript
const seconds = Math.floor(Date.now() / 1000);
const date = new Date(seconds * 1000);
Unix time in Go
now := time.Now().Unix()
date := time.Unix(now, 0).UTC()
Unix time in PHP
$seconds = time();
$date = gmdate('c', $seconds);
Unix time in SQL
SELECT EXTRACT(EPOCH FROM NOW()); -- PostgreSQL
SELECT UNIX_TIMESTAMP(); -- MySQL
Unix time in Java
long seconds = java.time.Instant.now().getEpochSecond();
java.time.Instant date = java.time.Instant.ofEpochSecond(seconds);
All programming examples →
-- PostgreSQL
SELECT TO_TIMESTAMP(1735689600);
-- MySQL
SELECT FROM_UNIXTIME(1735689600);