What is a Unix timestamp?
A Unix timestamp is a numeric representation of a specific moment, usually counted in seconds since January 1, 1970 UTC. It is useful across time zones because it can be converted into local dates anywhere.
Seconds and milliseconds
- Second timestamp - 10 digits, such as 1704067200, often used by backend systems and databases.
- Millisecond timestamp - 13 digits, such as 1704067200000, the format returned by JavaScript Date.now().
Common use cases
- API development - Pass time values consistently between clients and servers.
- Database storage - Store time as integers for simpler indexing and comparison.
- Log analysis - Sort and compare events with a unified time format.
- Cache expiration - Set precise expiration times for cached data.