What is Unix Epoch Time?
Unix Epoch time (also known as POSIX time or Unix timestamp) is a system for describing a point in time. It is defined as the number of seconds that have elapsed since 00:00:00 UTC on Thursday, 1 January 1970, minus leap seconds.
Why Jan 1, 1970? Historically, this was selected arbitrarily by Unix founders Ken Thompson and Dennis Ritchie because it was a convenient round date near the inception of Unix systems. Since then, it has become the universal standard for digital timekeeping.
How Computers Represent Epoch Time
In programming languages, epoch time is usually represented as a 32-bit or 64-bit integer. Here is how you can fetch the current Unix timestamp in different popular environments:
// JavaScript / Node.js
const currentTimestampInSeconds = Math.floor(Date.now() / 1000);
console.log("Unix Timestamp:", currentTimestampInSeconds);# Python
import time
current_timestamp = int(time.time())
print("Unix Timestamp:", current_timestamp)// Go (Golang)
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("Unix Timestamp:", time.Now().Unix())
}The Leap Second Complexity
Unix time is not a linear representation of physical time. Because of the Earth's irregular rotation, leap seconds are occasionally inserted into UTC. Unix time simply ignores leap seconds, meaning that a day in Unix time always has exactly 86,400 seconds. When a leap second occurs, the Unix timestamp repeats the previous second, causing a temporary double-tick.
