What is a Unix Timestamp?
A Unix timestamp (also known as Epoch time, POSIX time, or Unix epoch time) is a system for tracking points in time, defined as the total number of seconds that have elapsed since the Unix Epoch. The Unix Epoch occurred on January 1, 1970, at 00:00:00 UTC (Coordinated Universal Time). Since this standard began, it has counted upwards continuously, second by second, without taking leap seconds into account.
This simple numerical format makes it incredibly easy for computer systems, databases, and software applications to store, compare, and sort date and time values. Rather than dealing with complex human calendar systems, timezones, daylight saving transitions, or regional formatting differences, a database can store a single integer (like 1715769000). When displaying the time to a user, software translates this raw integer into localized human-readable date formats based on the client's timezone settings.
How to Generate a Unix Timestamp
You can easily generate the current Unix timestamp in major programming languages:
JavaScript
// Seconds
const seconds = Math.floor(Date.now() / 1000);
// Milliseconds (ms)
const milliseconds = Date.now();
Python
import time
# Seconds (integer)
seconds = int(time.time())
# Milliseconds
milliseconds = int(time.time() * 1000)
Go
package main
import (
"fmt"
"time"
)
func main() {
// Seconds
seconds := time.Now().Unix()
// Milliseconds
milliseconds := time.Now().UnixMilli()
}
Unix Timestamp Formats
Depending on the required precision, Unix timestamps can be represented in different lengths:
| Format | Length | Resolution | Example Value |
|---|---|---|---|
| Seconds | 10 digits | 1 second | 1715769000 |
| Milliseconds | 13 digits | 1 millisecond (1/1,000s) | 1715769000000 |
| Microseconds | 16 digits | 1 microsecond (1/1,000,000s) | 1715769000000000 |
| Nanoseconds | 19 digits | 1 nanosecond (1/1,000,000,000s) | 1715769000000000000 |