Unix Timestamp: A Complete Guide
Everything you need to know about Unix timestamps and time handling.
Unix timestamp is a way to track time as a running total of seconds.
What is Unix Timestamp?
Unix timestamp (also known as Epoch time) is the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC.
Current timestamp: When you read this, it's probably around 1700000000+
Why Use Unix Timestamp?
1. Universal: Same value regardless of timezone
2. Simple: Just a number, easy to store and compare
3. Precise: Can include milliseconds
4. Sortable: Numbers sort naturally
Common Conversions
JavaScript
// Current timestamp (seconds)
Math.floor(Date.now() / 1000)
// Current timestamp (milliseconds)
Date.now()
// Timestamp to Date
new Date(timestamp * 1000)
// Date to timestamp
Math.floor(date.getTime() / 1000)
Python
import time
from datetime import datetime
Current timestamp
time.time()
Timestamp to datetime
datetime.fromtimestamp(timestamp)
Datetime to timestamp
datetime.timestamp(dt)
Year 2038 Problem
32-bit systems store timestamps as signed 32-bit integers. The maximum value (2,147,483,647) represents January 19, 2038, 03:14:07 UTC.
Solution: Use 64-bit timestamps
Milliseconds vs Seconds
- Unix timestamp: Seconds (10 digits)
- JavaScript Date.now(): Milliseconds (13 digits)
Always check which format your API or database expects.
Use our Timestamp Converter to easily convert between formats.