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. JavaScript, Python, PHP, Java all use Unix time. Easier arithmetic (add/subtract seconds) than date strings.
Database Storage
Store timestamps as integers (4 or 8 bytes) instead of datetime strings (20+ bytes). Faster indexing and queries. Timezone-independent storage. Easy comparisons (>, <, =). Universal format across all database systems (MySQL, PostgreSQL, MongoDB).
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). Easy to parse in any programming language. Standard in OAuth tokens, JWT exp claims, and webhook payloads.
Log Analysis
Server logs, application logs, and system logs often use Unix timestamps. Easier to sort chronologically. Calculate time differences between events. Convert to local time for human readability. Essential for debugging and performance analysis.
Scheduling & Timers
Cron jobs, scheduled tasks, and timers use Unix time. Set future execution times as timestamps. Calculate "time until execution" with simple subtraction. Handle daylight saving time changes automatically. No timezone conversion issues.
Security & Expiration
Session expiration, token validity, cache TTL all use Unix timestamps. Simple check: if (current_time > expiry_time). No date parsing overhead. Used in SSL certificates, signed URLs, temporary access codes. Critical for security implementations.
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). This moment is considered "time zero" in Unix systems.
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 and programming languages. Example: 1700000000
Unix Timestamp (milliseconds): 13 digits. Used by JavaScript (Date.now()) and some APIs for higher precision. Example: 1700000000000
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 and wrap to negative values.
Solution: Modern systems use 64-bit timestamps, extending the range to year 292 billion. Most systems have migrated to 64-bit to avoid this issue.
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's a simple integer that represents a specific moment in time, independent of timezone.
Why do we use Unix timestamps?
Unix timestamps are: (1) Language-agnostic - work in any programming language, (2) Timezone-independent - always UTC-based, (3) Easy to compare and sort, (4) Compact storage - just an integer, (5) Simple arithmetic - add/subtract seconds directly, (6) No ambiguity - one format worldwide.
What's the difference between seconds and milliseconds?
Unix timestamps in seconds have 10 digits (e.g., 1700000000) and are standard in most systems. Milliseconds have 13 digits (e.g., 1700000000000) and provide more precision. JavaScript uses milliseconds by default. Convert by multiplying/dividing by 1000.
How do I get the current Unix timestamp?
Depends on language:
JavaScript: Math.floor(Date.now() / 1000)
Python: import time; time.time()
PHP: time()
Bash: date +%s
Or use this tool's "Current Timestamp" button!
Can Unix timestamps represent dates before 1970?
Yes! Negative Unix timestamps represent dates before January 1, 1970. For example, -86400 represents December 31, 1969 (one day before epoch). However, some systems may not handle negative timestamps correctly.
What is the Year 2038 problem?
32-bit systems can only store timestamps up to 2,147,483,647 (January 19, 2038, 03:14:07 UTC). After this, timestamps overflow. Modern 64-bit systems solve this, extending the range to year 292 billion. Most systems have already migrated to avoid this issue.
How do I handle timezones with Unix timestamps?
Unix timestamps are always in UTC (Coordinated Universal Time). When converting to human-readable format, specify the timezone. The timestamp itself doesn't change — only the displayed time changes. Store in UTC, convert to local timezone for display.
What's the maximum Unix timestamp value?
32-bit signed: 2,147,483,647 (Jan 19, 2038)
32-bit unsigned: 4,294,967,295 (Feb 7, 2106)
64-bit signed: ~292 billion years in the future
Modern systems use 64-bit, eliminating practical limitations.
How accurate are Unix timestamps?
Standard Unix timestamps (seconds) have 1-second precision. Millisecond timestamps have 0.001-second precision (1ms). Some systems support microseconds (6 digits after decimal) or nanoseconds (9 digits). For most applications, seconds or milliseconds are sufficient.
Why doesn't my timestamp convert correctly?
Common issues:
• Milliseconds vs seconds confusion (check digit count: 10 = seconds, 13 = milliseconds)
• Timezone misinterpretation (Unix time is always UTC)
• Invalid timestamp (negative values, or exceeding maximum for your system)
• Programming language differences in how they handle timestamps
Can I use Unix timestamps in URLs?
Yes! Unix timestamps are URL-safe (just digits). Commonly used in cache-busting (style.css?v=1700000000), temporary links (expires=1700000000), or API endpoints (/api/logs?since=1700000000). Much cleaner than URL-encoded date strings.
How do I calculate time differences?
Simply subtract timestamps:difference = timestamp2 - timestamp1
Result is in seconds. Divide by 60 for minutes, 3600 for hours, 86400 for days. Example: 1700000000 - 1699999000 = 1000 seconds = ~16.7 minutes.