Unix Timestamp
Convert Unix timestamps in seconds, milliseconds, microseconds or nanoseconds to dates in any time zone, and dates back to epoch time.
Timestamp → date
Date → timestamp
What is a Unix timestamp?
A Unix timestamp (also called epoch time or POSIX time) is the number of seconds since 1 January 1970 at 00:00:00 UTC, not counting leap seconds. It is the same everywhere in the world, which is why logs, databases and APIs use it. JavaScript and Java usually use milliseconds instead of seconds, so a 13-digit number is almost always milliseconds. This converter detects the unit from the number of digits.
Get the current timestamp in code
JavaScript Math.floor(Date.now() / 1000) // seconds; Date.now() = ms
Python int(time.time()) # import time
Go time.Now().Unix() // UnixMilli() for ms
Java Instant.now().getEpochSecond() // System.currentTimeMillis() for ms
C# DateTimeOffset.UtcNow.ToUnixTimeSeconds()
PHP time()
Bash date +%s
PostgreSQL SELECT extract(epoch FROM now());
MySQL SELECT UNIX_TIMESTAMP();Convert a timestamp to a date in code
JavaScript new Date(1764230400 * 1000).toISOString()
Python datetime.fromtimestamp(1764230400, tz=timezone.utc)
Go time.Unix(1764230400, 0).UTC()
Java Instant.ofEpochSecond(1764230400)
C# DateTimeOffset.FromUnixTimeSeconds(1764230400)
Bash date -u -d @1764230400 # macOS: date -u -r 1764230400
PostgreSQL SELECT to_timestamp(1764230400);
MySQL SELECT FROM_UNIXTIME(1764230400);The year 2038 problem
Systems that store seconds in a signed 32-bit integer run out on 19 January 2038 at 03:14:07 UTC (2147483647). After that the number wraps to a negative value and jumps back to 1901. Use 64-bit integers for timestamps.