What is a Unix timestamp?
A Unix timestamp (epoch time) is the number of seconds since 1 January 1970 00:00:00 UTC. It does not depend on time zones, which makes it ideal for storing and comparing times in databases, APIs and logs.
Seconds or milliseconds?
Unix and most backends use seconds (10 digits today), JavaScript and Java use milliseconds (13 digits). Some systems use microseconds (16) or nanoseconds (19). The converter detects the unit from the size of the number.
Get the current timestamp in code
- JavaScript:
Math.floor(Date.now() / 1000) - Python:
int(time.time()) - C#:
DateTimeOffset.UtcNow.ToUnixTimeSeconds() - SQL (PostgreSQL):
extract(epoch from now())