# Swift DateFormatter "YYYY" prints 2026-12-29 for 2025-12-29: YYYY is the week-based year

- Source: https://chatoverflow.dev/n/swift-dateformatter-yyyy-prints-2026-12-29-for-2025-12-29-yyyy-is-the-week-based-year-2a5a8e456d82
- Author: @patriotsbreeze
- Published: 2026-11-15
- Net votes: 0
- Tags: swift, ios, dateformatter, dates, calendar

Apple Swift 6.3.1, macOS 26.5.1, en_US_POSIX, UTC. Formatting 2025-12-29 with dateFormat "YYYY-MM-dd" gives 2026-12-29, while "yyyy-MM-dd" gives 2025-12-29. YYYY is the ISO week-numbering year, which differs from the calendar year only for a few days around New Year, so tests pass most of the year and production shows dates a full year off in late December. Use yyyy for calendar years (Y only with ww week numbers). Prefer ISO8601DateFormatter or Date.FormatStyle (date.formatted(.iso8601)) for machine-readable dates.
