RFC 3339 Timestamps: The Only Correct Date Format (And Why Everything Else Is Wrong)
Unix timestamps, ISO 8601, RFC 2822, custom formats — there are dozens of date representations. Only one is correct for APIs. Here's why.
Keine Diskussion. Keine Ausnahmen. RFC 3339 ist das einzige korrekte Format für API-Daten.
Let me explain why, with the precision that this topic demands.
The Problem
Every developer has experienced this: you receive a date string from an API and have no idea how to parse it.
"2024-03-18T14:30:00Z"
"Mon, 18 Mar 2024 14:30:00 GMT"
"1710771000"
"03/18/2024 2:30 PM"
"18.03.2024"
"2024/03/18"
Six formats. Six different APIs. Six different parsing functions. This is unacceptable.
The Standard: RFC 3339
RFC 3339 is a profile of ISO 8601. It specifies exactly one format:
YYYY-MM-DDTHH:MM:SSZ
Or with timezone offset:
YYYY-MM-DDTHH:MM:SS+05:30
Why This Format Wins
- Unambiguous —
2024-03-18can only mean March 18th. Not August 3rd (US format confusion). - Sortable — Lexicographic sort = chronological sort. No conversion needed.
- Timezone-aware — The
Zor+05:30suffix eliminates timezone guessing. - Machine-parseable — Every language has a built-in parser for this format.
- Human-readable — Unlike Unix timestamps (
1710771000), you can read it.
Converting Between Formats
| Format | Example | Parseable? |
|---|---|---|
| RFC 3339 | 2024-03-18T14:30:00Z |
✅ Universal |
| Unix timestamp | 1710771000 |
✅ But unreadable |
| ISO 8601 | 20240318T143000Z |
⚠️ Compact variant |
| RFC 2822 | Mon, 18 Mar 2024 14:30:00 GMT |
⚠️ Email only |
| US format | 03/18/2024 |
❌ Ambiguous internationally |
| EU format | 18.03.2024 |
❌ Ambiguous internationally |
Use a Timestamp Converter to convert between RFC 3339, Unix timestamps, and human-readable formats.
Implementation in Code
JavaScript
// Current time in RFC 3339
const now = new Date().toISOString(); // "2024-03-18T14:30:00.000Z"
// Parse RFC 3339
const date = new Date("2024-03-18T14:30:00Z");
Python
from datetime import datetime, timezone
# Current time in RFC 3339
now = datetime.now(timezone.utc).isoformat()
# Parse RFC 3339
date = datetime.fromisoformat("2024-03-18T14:30:00+00:00")
Go
// RFC 3339 is a built-in constant
now := time.Now().Format(time.RFC3339)
parsed, _ := time.Parse(time.RFC3339, "2024-03-18T14:30:00Z")
The Unix Timestamp Debate
"But Unix timestamps are simpler!"
No. They're not.
1710771000— Is this seconds or milliseconds? You don't know.- No timezone information — You must assume UTC or get it wrong.
- Unreadable — Humans can't interpret
1710771000. - Year 2038 problem — 32-bit signed integers overflow in 2038.
RFC 3339 solves all four problems.
My Rule for API Design
When designing APIs:
- Request parameters: Accept RFC 3339 only
- Response fields: Return RFC 3339 only
- Error messages: Include RFC 3339 timestamps
- Logs: Use RFC 3339 for consistency
No exceptions. No "but the legacy system uses..." — wrap the legacy system.
Convert timestamps between any format with our free Timestamp Converter — RFC 3339, Unix, and human-readable, all in one tool.
Try It Yourself
Put what you've learned into practice with our free online tools.
Related Articles
ISO 8601: The Only Date Format You Should Ever Use
I will say this once: use ISO 8601 for all date representations. No exceptions...
Why Your API Design Is Boring (And How to Disrupt It)
I looked at Stripe's API and thought: this is boring. Then I understood: boring is brilliant...
Designing APIs for Mobile Money: Lessons from M-Pesa
When your API serves 30 million users on $50 phones, every byte matters...