Timestamp Conversion Made Simple: Unix, ISO 8601, and Beyond
Confused by 1709251200? This guide demystifies every timestamp format you'll encounter — Unix epoch, ISO 8601, RFC 2822 — with instant conversion tricks and code examples.
Timestamp Conversion Made Simple: Unix, ISO 8601, and Beyond
If you've ever stared at 1709251200 and wondered what date it represents, you're not alone. Timestamps come in dozens of formats, and converting between them is a daily task for developers working with APIs, databases, logs, and scheduled jobs.
This guide covers every format you'll encounter and shows you how to convert between them instantly — with code examples in JavaScript, Python, Java, and the command line.
The Most Common Timestamp Formats
| Format | Example | Where You'll See It |
|---|---|---|
| Unix (seconds) | 1709251200 |
APIs, databases, Linux |
| Unix (milliseconds) | 1709251200000 |
JavaScript, Java |
| ISO 8601 | 2024-03-01T00:00:00Z |
JSON APIs, modern systems |
| RFC 2822 | Fri, 01 Mar 2024 00:00:00 +0000 |
Email headers, RSS |
| Human readable | March 1, 2024 |
UI display |
Unix Timestamp Explained
A Unix timestamp counts the seconds since January 1, 1970 (UTC). It's elegant in its simplicity:
0= January 1, 1970, 00:00:00 UTC1709251200= March 1, 2024, 00:00:00 UTC253402300799= December 31, 9999, 23:59:59 UTC
Why Unix Timestamps Are Popular
- No timezone ambiguity — it's always UTC
- Easy to compare — bigger number = later date
- Efficient storage — just an integer
- No formatting issues — no locale, no parsing ambiguity
The Y2038 Problem
Unix timestamps stored as 32-bit signed integers will overflow on January 19, 2038. Most modern systems use 64-bit integers, which won't overflow for another 292 billion years.
ISO 8601 — The Gold Standard
ISO 8601 is the international standard for date and time representation:
YYYY-MM-DDTHH:MM:SSZ
Breaking it down:
YYYY— 4-digit yearMM— 2-digit month (01-12)DD— 2-digit day (01-31)T— separator between date and timeHH:MM:SS— hours, minutes, secondsZ— UTC timezone (or+05:30for offset)
Variations you'll see:
2024-03-01 // Date only
2024-03-01T00:00:00Z // Full datetime, UTC
2024-03-01T00:00:00+08:00 // With timezone offset
20240301T000000Z // Compact form (no separators)
Quick Conversion Recipes
JavaScript
// Unix seconds → Date
const date = new Date(1709251200 * 1000);
// Unix milliseconds → Date
const date = new Date(1709251200000);
// ISO 8601 → Date
const date = new Date('2024-03-01T00:00:00Z');
// Date → Unix seconds
const unix = Math.floor(date.getTime() / 1000);
// Date → ISO 8601
const iso = date.toISOString(); // "2024-03-01T00:00:00.000Z"
// Current timestamp
const now = Math.floor(Date.now() / 1000); // Unix seconds
Python
from datetime import datetime, timezone
# Unix seconds → datetime
dt = datetime.fromtimestamp(1709251200, tz=timezone.utc)
# ISO 8601 → datetime
dt = datetime.fromisoformat('2024-03-01T00:00:00+00:00')
# datetime → Unix seconds
unix = int(dt.timestamp())
# datetime → ISO 8601
iso = dt.isoformat() # '2024-03-01T00:00:00+00:00'
# Current timestamp
import time
now = int(time.time()) # Unix seconds
Java
import java.time.*;
import java.time.format.DateTimeFormatter;
// Unix seconds → Instant
Instant instant = Instant.ofEpochSecond(1709251200);
// Unix milliseconds → Instant
Instant instant = Instant.ofEpochMilli(1709251200000L);
// Instant → ISO 8601
String iso = instant.toString(); // "2024-03-01T00:00:00Z"
// ISO 8601 → Instant
Instant parsed = Instant.parse("2024-03-01T00:00:00Z");
// With timezone
ZonedDateTime zdt = instant.atZone(ZoneId.of("America/New_York"));
// Current timestamp
long now = Instant.now().getEpochSeconds();
Bash / Command Line
# Current Unix timestamp
date +%s
# Unix timestamp → human readable
date -d @1709251200
# Human readable → Unix timestamp
date -d "2024-03-01" +%s
# ISO 8601 format
date -u +"%Y-%m-%dT%H:%M:%SZ"
Common Pitfalls
1. Seconds vs Milliseconds
The #1 mistake: JavaScript's Date constructor expects milliseconds, but most APIs return seconds.
// WRONG — treats seconds as milliseconds (year 55913)
new Date(1709251200);
// CORRECT — multiply by 1000
new Date(1709251200 * 1000);
2. Timezone Confusion
Unix timestamps are always UTC. But when displaying them, you need to know the user's timezone:
const unix = 1709251200;
const date = new Date(unix * 1000);
// UTC
date.toUTCString(); // "Fri, 01 Mar 2024 00:00:00 GMT"
// Local timezone
date.toLocaleString(); // "2/29/2024, 4:00:00 PM" (if in PST)
3. Leap Seconds
Unix time ignores leap seconds. For most applications this doesn't matter, but if you're building something that requires exact astronomical precision, be aware.
Timestamps in Databases
Different databases handle timestamps differently:
| Database | Type | Storage | Timezone |
|---|---|---|---|
| PostgreSQL | TIMESTAMPTZ |
8 bytes | Stored as UTC, converted on retrieval |
| MySQL | TIMESTAMP |
4 bytes | Stored as UTC, converted to session timezone |
| MySQL | DATETIME |
8 bytes | No timezone conversion |
| SQLite | TEXT or INTEGER |
Variable | No native type — use Unix seconds or ISO strings |
| MongoDB | Date |
8 bytes | Always UTC (milliseconds since epoch) |
Best practice: Always store timestamps in UTC. Convert to local timezone only at the display layer.
Relative Time Formatting
Often you need to display timestamps as "3 days ago" or "in 2 hours":
function timeAgo(date) {
const seconds = Math.floor((new Date() - date) / 1000);
const intervals = [
{ label: 'year', seconds: 31536000 },
{ label: 'month', seconds: 2592000 },
{ label: 'week', seconds: 604800 },
{ label: 'day', seconds: 86400 },
{ label: 'hour', seconds: 3600 },
{ label: 'minute', seconds: 60 },
{ label: 'second', seconds: 1 }
];
for (const interval of intervals) {
const count = Math.floor(seconds / interval.seconds);
if (count >= 1) {
return count === 1
? `1 ${interval.label} ago`
: `${count} ${interval.label}s ago`;
}
}
return 'just now';
}
// Using Intl.RelativeTimeFormat (modern browsers)
const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
rtf.format(-3, 'day'); // "3 days ago"
rtf.format(2, 'hour'); // "in 2 hours"
Timezone Best Practices
Handling timezones correctly prevents countless bugs:
- Store everything in UTC — databases, APIs, internal calculations
- Convert at the edges — only convert to local time when displaying to users
- Use IANA timezone names (
America/New_York) not abbreviations (EST) — abbreviations are ambiguous - Handle DST transitions — some days have 23 or 25 hours
- Let the browser handle display —
Intl.DateTimeFormatrespects user locale:
const date = new Date('2024-03-01T00:00:00Z');
new Intl.DateTimeFormat('en-US', {
timeZone: 'America/New_York',
dateStyle: 'full',
timeStyle: 'long'
}).format(date);
// "Thursday, February 29, 2024 at 7:00:00 PM EST"
Common API Timestamp Formats
When integrating with third-party APIs, you'll encounter various formats:
| API | Format | Example |
|---|---|---|
| Stripe | Unix seconds | 1709251200 |
| GitHub | ISO 8601 | 2024-03-01T00:00:00Z |
| Twitter/X | RFC 3339 | Fri Mar 01 00:00:00 +0000 2024 |
| Slack | Unix seconds (float) | 1709251200.123456 |
| AWS | ISO 8601 | 20240301T000000Z |
| Google Calendar | RFC 3339 | 2024-03-01T00:00:00-05:00 |
Always check the API documentation for the expected format before sending or parsing timestamps.
Try It Now
Need a quick conversion? Our Timestamp Converter lets you convert between Unix timestamps, ISO 8601, and human-readable dates instantly — just paste any format and it auto-detects.
Cheat Sheet
| I Have | I Want | Formula |
|---|---|---|
| Unix seconds | milliseconds | × 1000 |
| Unix milliseconds | seconds | ÷ 1000 |
| Unix seconds | ISO 8601 | new Date(s*1000).toISOString() |
| ISO 8601 | Unix seconds | Math.floor(new Date(iso).getTime()/1000) |
| Unix seconds | readable | new Date(s*1000).toLocaleString() |
Summary
- Unix timestamps are simple counters from 1970 — great for storage and APIs
- ISO 8601 is human-readable and timezone-aware — great for display and data exchange
- Always check whether you're dealing with seconds or milliseconds
- Store in UTC, display in the user's local timezone
- Use built-in tools — every language has date conversion utilities, no library needed
- Be explicit about timezones in your APIs and database schemas
Once you understand the formats and follow these conventions, timestamp conversion becomes trivial. And when you need it done fast, just use a converter tool.
Need a quick conversion? Our Timestamp Converter lets you convert between Unix timestamps, ISO 8601, and human-readable dates instantly — just paste any format and it auto-detects.
Try It Yourself
Put what you've learned into practice with our free online tools.