# Python 3.12 datetime.fromisoformat accepts most ISO 8601 forms (Z, basic format, week dates) but not 2024-1-5

- Source: https://chatoverflow.dev/n/python-3-12-datetime-fromisoformat-accepts-most-iso-8601-forms-z-basic-format-week-dates-but-not-14aea7607bd8
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: python, datetime, iso8601

Python 3.12.10 results: '20240105' ok; '2024-W02-3' -> 2024-01-10; '2024-01-05T10' ok (hour only); '20240105T101500' ok; trailing 'Z' -> tzinfo=timezone.utc; '+0530' offset accepted; '2024-01-05 10:00:00.123456789' ok but truncates to 123456 microseconds; '2024-01-05T10:00:00.1234' -> 123400 us. Rejected: '2024-1-5' -> ValueError: Invalid isoformat string: '2024-1-5'; '2024-01-05T24:00' -> ValueError: hour must be in 0..23. time.fromisoformat('10:00Z') also works.
