Unix Timestamp Converter
Convert Unix timestamps (Epoch time) to readable dates and vice versa. Supports seconds and milliseconds. Works with all timezones. Essential tool for developers and system administrators.
Unix Time Converter
How to use:
- Enter a Unix timestamp to convert it to human-readable date
- Select a date and time to convert it to Unix timestamp
- Unix time is the number of seconds since January 1, 1970 (UTC)
Why Use Unix Timestamps?
Unix timestamps are fundamental to programming and system operations
Programming & Development
Unix timestamps are language-agnostic. Store dates as integers in databases, APIs, and logs. No timezone ambiguity — always UTC-based.
Database Storage
Store timestamps as integers (4 or 8 bytes) instead of datetime strings (20+ bytes). Faster indexing and queries. Timezone-independent storage.
API Integration
REST APIs commonly use Unix timestamps for created_at, updated_at, expires_at fields. No date format ambiguity (MM/DD vs DD/MM).
Log Analysis
Server logs, application logs, and system logs often use Unix timestamps. Easier to sort chronologically. Calculate time differences between events.
Scheduling & Timers
Cron jobs, scheduled tasks, and timers use Unix time. Set future execution times as timestamps. Handle daylight saving time changes automatically.
Security & Expiration
Session expiration, token validity, cache TTL all use Unix timestamps. Used in SSL certificates, signed URLs, temporary access codes.
Understanding Unix Timestamps
What is Unix Time?
Unix time (also called Epoch time or POSIX time) is the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC (the Unix Epoch).
Example:
0= January 1, 1970, 00:00:00 UTC1000000000= September 9, 2001, 01:46:40 UTC1700000000= November 14, 2023, 22:13:20 UTC
Seconds vs Milliseconds
Unix Timestamp (seconds): 10 digits. Standard for most Unix systems.
Unix Timestamp (milliseconds): 13 digits. Used by JavaScript.
Conversion: Multiply seconds by 1000 to get milliseconds. Divide milliseconds by 1000 to get seconds.
Why 1970?
Unix was developed in the late 1960s. The creators chose January 1, 1970 as the epoch for practical reasons:
- It was close to when Unix was being developed
- Starting from a round year (1970) was clean and memorable
- It became the de facto standard and stuck
- All negative timestamps represent dates before 1970
The Year 2038 Problem
32-bit systems can only store timestamps up to 2,147,483,647 seconds (January 19, 2038, 03:14:07 UTC). After this, 32-bit timestamps overflow.
Solution: Modern systems use 64-bit timestamps, extending the range to year 292 billion.
Working with Unix Timestamps in Code
JavaScript / TypeScript
// Get current Unix timestamp (milliseconds)
const now = Date.now(); // 1700000000000
// Get current Unix timestamp (seconds)
const nowSeconds = Math.floor(Date.now() / 1000); // 1700000000
// Convert timestamp to Date
const date = new Date(1700000000 * 1000);
console.log(date.toISOString()); // "2023-11-14T22:13:20.000Z"
// Convert Date to timestamp
const timestamp = Math.floor(new Date('2023-11-14').getTime() / 1000);
// Format human-readable
const readable = new Date(1700000000 * 1000).toLocaleString();
console.log(readable); // "11/14/2023, 10:13:20 PM"Python
import time
from datetime import datetime
# Get current Unix timestamp
now = time.time() # 1700000000.123
# Convert timestamp to datetime
dt = datetime.fromtimestamp(1700000000)
print(dt) # 2023-11-14 22:13:20
# Convert datetime to timestamp
timestamp = datetime(2023, 11, 14).timestamp()
# Format human-readable
readable = datetime.fromtimestamp(1700000000).strftime('%Y-%m-%d %H:%M:%S')
print(readable) # "2023-11-14 22:13:20"PHP
// Get current Unix timestamp
$now = time(); // 1700000000
// Convert timestamp to date
$date = date('Y-m-d H:i:s', 1700000000);
echo $date; // "2023-11-14 22:13:20"
// Convert date to timestamp
$timestamp = strtotime('2023-11-14 22:13:20');
// Using DateTime
$dt = new DateTime('@1700000000');
echo $dt->format('Y-m-d H:i:s'); // "2023-11-14 22:13:20"MySQL / SQL
-- Convert timestamp to datetime
SELECT FROM_UNIXTIME(1700000000);
-- Result: '2023-11-14 22:13:20'
-- Convert datetime to timestamp
SELECT UNIX_TIMESTAMP('2023-11-14 22:13:20');
-- Result: 1700000000
-- Get current timestamp
SELECT UNIX_TIMESTAMP();
-- Query with timestamp
SELECT * FROM logs
WHERE created_at > 1700000000;Frequently Asked Questions
What is a Unix timestamp?
A Unix timestamp is the number of seconds (or milliseconds) that have elapsed since January 1, 1970, 00:00:00 UTC (the Unix Epoch). It is a simple integer that represents a specific moment in time, independent of timezone.
Why do we use Unix timestamps?
Unix timestamps are language-agnostic, timezone-independent, easy to compare and sort, compact for storage, and allow simple arithmetic.
What is the difference between seconds and milliseconds?
Unix timestamps in seconds have 10 digits (e.g., 1700000000). Milliseconds have 13 digits (e.g., 1700000000000) and provide more precision. JavaScript uses milliseconds by default.
How do I get the current Unix timestamp?
JavaScript: Math.floor(Date.now() / 1000). Python: time.time(). PHP: time(). Bash: date +%s.
Can Unix timestamps represent dates before 1970?
Yes! Negative Unix timestamps represent dates before January 1, 1970. For example, -86400 represents December 31, 1969.
How do I handle timezones with Unix timestamps?
Unix timestamps are always in UTC. When converting to human-readable format, specify the timezone. Store in UTC, convert to local timezone for display.