Unix Timestamp Converter
Convert between Unix timestamps and human-readable dates
177809709501617780970952026-05-06T19:51:35.016Z- Unix Timestamp: Number of seconds (or milliseconds) since January 1, 1970 00:00:00 UTC (Unix Epoch)
- Seconds: Used by many APIs and databases (10 digits, e.g., 1609459200)
- Milliseconds: Used by JavaScript (13 digits, e.g., 1609459200000)
- ISO 8601: Standard date format (YYYY-MM-DDTHH:mm:ss.sssZ)
๐ How to Use
- View the current Unix timestamp at the top (updates in real-time)
- To convert timestamp to date: Enter a Unix timestamp (seconds or milliseconds) in the first field
- Click "Now" to quickly insert the current timestamp
- To convert date to timestamp: Use the datetime picker in the second field
- View multiple date formats including ISO 8601, RFC 2822, and local format
- Click "Copy" buttons to copy individual values or "Copy All" for all formats
About the Unix Timestamp Converter
The Unix Timestamp Converter is a free, browser-based tool that instantly converts between Unix timestamps (Epoch time) and human-readable dates in both directions. Whether you're debugging API responses with timestamps, scheduling cron jobs, analyzing log files, or working with database time fields, this tool provides real-time conversion with multiple date format outputs. Perfect for developers, system administrators, database engineers, and anyone working with Unix timestamps across different systems and programming languages. All conversion happens locally in your browser with complete privacy.
Key Features:
- Bidirectional conversion: timestamp to date and date to timestamp
- Supports both seconds (10 digits) and milliseconds (13 digits) timestamps
- Real-time current timestamp display with live updates
- Multiple output formats: ISO 8601, RFC 2822, UTC, Local time
- One-click "Now" button for current timestamp insertion
- 100% client-side processing - no data sent to servers
Common Use Cases:
- API Debugging: Convert timestamps in API responses and request logs to readable dates for debugging
- Database Queries: Convert between timestamp integers and dates when querying time-series data
- Cron Job Scheduling: Calculate exact Unix timestamps for scheduled tasks and automation
- Log Analysis: Parse server logs with Unix timestamps to identify when events occurred
- Token Expiration: Verify JWT token exp and iat claims or session expiration times (decode tokens with our JWT Debugger)
Unix Timestamp Examples & Implementation
Getting Current Timestamp (Multiple Languages)
// JavaScript (milliseconds):
const timestampMs = Date.now();
console.log(timestampMs); // 1704067200000
// JavaScript (seconds):
const timestampSec = Math.floor(Date.now() / 1000);
console.log(timestampSec); // 1704067200
// Python (seconds):
import time
timestamp = time.time()
print(timestamp) # 1704067200.123
// PHP (seconds):
$timestamp = time();
echo $timestamp; // 1704067200
// SQL (MySQL):
SELECT UNIX_TIMESTAMP(); -- 1704067200
// Bash/Shell:
date +%s # 1704067200 Use case: Get current timestamp across different programming environments
Converting Timestamp to Date
// JavaScript:
const timestamp = 1704067200;
const date = new Date(timestamp * 1000); // Convert seconds to ms
console.log(date.toISOString());
// "2024-01-01T00:00:00.000Z"
console.log(date.toLocaleString('en-US'));
// "1/1/2024, 12:00:00 AM"
// Python:
import datetime
timestamp = 1704067200
date = datetime.datetime.fromtimestamp(timestamp)
print(date.strftime('%Y-%m-%d %H:%M:%S'))
# "2024-01-01 00:00:00"
// PHP:
$timestamp = 1704067200;
echo date('Y-m-d H:i:s', $timestamp);
// "2024-01-01 00:00:00"
// SQL (MySQL):
SELECT FROM_UNIXTIME(1704067200);
-- "2024-01-01 00:00:00" Use case: Display timestamps as human-readable dates in applications
Converting Date to Timestamp
// JavaScript:
const date = new Date('2024-01-01T00:00:00Z');
const timestamp = Math.floor(date.getTime() / 1000);
console.log(timestamp); // 1704067200
// Python:
import datetime
date = datetime.datetime(2024, 1, 1, 0, 0, 0)
timestamp = int(date.timestamp())
print(timestamp) # 1704067200
// PHP:
$date = '2024-01-01 00:00:00';
$timestamp = strtotime($date);
echo $timestamp; // 1704067200
// SQL (MySQL):
SELECT UNIX_TIMESTAMP('2024-01-01 00:00:00');
-- 1704067200 Use case: Store dates as timestamps in databases for efficient querying
Timezone Handling
// JavaScript - Display timestamp in specific timezone:
const timestamp = 1704067200;
const date = new Date(timestamp * 1000);
// New York time:
console.log(date.toLocaleString('en-US', {
timeZone: 'America/New_York'
}));
// "12/31/2023, 7:00:00 PM" (UTC-5)
// Tokyo time:
console.log(date.toLocaleString('en-US', {
timeZone: 'Asia/Tokyo'
}));
// "1/1/2024, 9:00:00 AM" (UTC+9)
// UTC time (always):
console.log(date.toISOString());
// "2024-01-01T00:00:00.000Z"
// Best practice: Store in UTC, display in local timezone Use case: Handle timestamps across multiple timezones in global applications
Database Time Queries
-- PostgreSQL: Find records from last 24 hours
SELECT * FROM events
WHERE created_at > EXTRACT(EPOCH FROM NOW()) - 86400;
-- MySQL: Records between two timestamps
SELECT * FROM orders
WHERE order_time BETWEEN 1704067200 AND 1704153600;
-- MongoDB: Query with timestamp
db.logs.find({
timestamp: {
$gte: 1704067200,
$lt: 1704153600
}
});
-- Calculate age from timestamp:
SELECT
name,
(UNIX_TIMESTAMP() - birth_timestamp) / 31536000 AS age_years
FROM users; Use case: Query time-series data efficiently using timestamp comparisons
JWT Token Expiration Handling
// Check if JWT token is expired:
function isTokenExpired(token) {
const payload = JSON.parse(atob(token.split('.')[1]));
const expTimestamp = payload.exp; // Unix timestamp (seconds)
const nowTimestamp = Math.floor(Date.now() / 1000);
return nowTimestamp > expTimestamp;
}
// Create token with 1 hour expiration:
const payload = {
userId: 123,
email: '[email protected]',
iat: Math.floor(Date.now() / 1000), // Issued at
exp: Math.floor(Date.now() / 1000) + 3600 // Expires in 1 hour
};
// Display token expiration time:
const expDate = new Date(payload.exp * 1000);
console.log(`Token expires at: ${expDate.toLocaleString()}`);
// "Token expires at: 1/1/2024, 1:00:00 PM" Use case: Manage JWT token expiration and session timing
โ Frequently Asked Questions
What is a Unix timestamp (Epoch time)?
A Unix timestamp (also called Epoch time or POSIX time) is the number of seconds or milliseconds that have elapsed since the Unix Epoch: January 1, 1970 00:00:00 UTC (Coordinated Universal Time). It's a universal time representation used across programming languages, databases, and operating systems. For example, timestamp 1640000000 represents December 20, 2021 at 13:33:20 UTC.
What is the difference between seconds and milliseconds timestamps?
Unix timestamps in seconds are 10 digits long (e.g., 1640000000) and count seconds since 1970. They're used in PHP (time()), Python (time.time()), Unix systems, and many APIs. Milliseconds timestamps are 13 digits long (e.g., 1640000000000) and count milliseconds since 1970. They're used in JavaScript (Date.now()), Java (System.currentTimeMillis()), and databases like MongoDB. To convert: multiply seconds by 1000 for milliseconds, or divide milliseconds by 1000 for seconds.
Why use Unix timestamps instead of formatted dates?
Unix timestamps have key advantages: (1) Timezone-independent - no ambiguity about timezones; (2) Easy sorting and comparison - just compare numbers; (3) Compact storage - integers are efficient; (4) Universal compatibility - works across all programming languages; (5) No date parsing issues - no month/day ambiguity. Perfect for APIs, databases, logging, and data synchronization. Convert to human-readable format only for display.
How do I get the current Unix timestamp?
Click the "Now" button in this tool for the current timestamp. In code: JavaScript: Date.now() (milliseconds) or Math.floor(Date.now()/1000) (seconds); Python: import time; time.time(); PHP: time(); SQL: UNIX_TIMESTAMP(); Bash: date +%s. The tool displays both second and millisecond timestamps with real-time updates.
What date formats does this tool support?
The tool provides multiple output formats: ISO 8601 (2024-01-15T10:30:00Z) - standard international format; RFC 2822 (Mon, 15 Jan 2024 10:30:00 GMT) - email header format; Local format (varies by browser locale); UTC format; and custom date/time components. You can copy individual formats or all formats at once for comprehensive documentation.
Can I convert future dates and past dates?
Yes! You can convert any date - past, present, or future. The tool handles dates from January 1, 1970 (timestamp 0) to well beyond 2100 (timestamp 4102444800+). Negative timestamps represent dates before 1970 (though less common). This is useful for scheduling future events, historical data analysis, and testing edge cases in applications.
How do I handle timezones with Unix timestamps?
Unix timestamps are always in UTC (timezone-independent). When converting timestamp to date, specify the timezone for display purposes. In JavaScript: new Date(timestamp).toLocaleString("en-US", {timeZone: "America/New_York"}). When converting date to timestamp, ensure your input date is interpreted correctly (local vs UTC). Best practice: store timestamps in UTC, convert to local timezone only for display.
What is the Year 2038 problem?
The Year 2038 problem affects 32-bit systems storing timestamps as signed integers. Maximum value is 2,147,483,647 (January 19, 2038 03:14:07 UTC). After this, timestamps overflow and wrap to negative numbers. Modern 64-bit systems don't have this issue (can represent dates until year 292 billion+). If you're using 32-bit systems, plan migration to 64-bit before 2038.