Swift Date Formatter & ISO 8601 Playground
Test Apple DateFormatter tokens, explore ISO 8601 patterns, and generate modern iOS 15+ Date.now.formatted() code with live preview.
let formatter = DateFormatter()
formatter.dateFormat = "EEEE, MMMM d, yyyy 'at' h:mm a"
formatter.locale = Locale(identifier: "en_US")
let dateString = formatter.string(from: Date())
// Output: "Tues13PMy, October 13, 2026 PMt h:48 PM"// iOS 15+ Swift Date Formatting API
let formatted = Date.now.formatted(
.dateTime
.year()
.month(.wide)
.day()
.hour()
.minute()
)Date Format Token Cheatsheet
yyyy4-digit year (e.g. 2026)yy2-digit year (e.g. 26)MMMMFull month (e.g. October)MMMShort month (e.g. Oct)MM2-digit month (01–12)dd2-digit day of month (01–31)dDay of month without leading zero (1–31)EEEEFull weekday (e.g. Monday)EAbbreviated weekday (e.g. Mon)HH24-hour hour (00–23)hh12-hour hour (01–12)mmMinute (00–59)ssSecond (00–59)aAM/PM period indicatorZ / zzzTimezone offset (+0100 / GMT+1)Modern Swift Date Formatting Guidelines
DateFormatter is Expensive
Creating instances of DateFormatter() has heavy memory overhead. Always reuse a single static instance or prefer iOS 15’s lightweight .formatted() API.
Locale en_US_POSIX
When parsing fixed internet dates (RFC 3339 / ISO 8601), always set locale to en_US_POSIX to avoid unexpected 12-hour/24-hour phone setting overrides.
ISO8601DateFormatter
Use Apple’s dedicated ISO8601DateFormatter() with .withInternetDateTime for standard API payloads with timezone offsets.
Build full iPhone apps without touching Xcode
Enjoying this free Date Formatter? Thorous turns your natural language prompts into compiled native SwiftUI apps, with real-time iOS simulator streaming and visual on-screen editing.
Native Mac app · macOS 14 Sonoma or later · Apple silicon & Intel