Regex Date y Time Patrones Referencia
Referencia para date, time, y ISO 8601 validation regex patrones.
ISO 8601 Patterns
Date only: ^\d{4}-\d{2}-\d{2}$ (YYYY-MM-DD). Date and time: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$ (UTC). With offset: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}$. With milliseconds: add .\d{3} before the zone. ISO 8601 also allows week dates (YYYY-Www-D) and ordinal dates (YYYY-DDD). The T separator can be a space by mutual agreement. For full validation including leap years, use Date.parse or a date library, not regex alone.
- date
- YYYY-MM-DD
- datetime
- YYYY-MM-DDTHH:MM:SSZ
- offset
- +HH:MM or -HH:MM
ISO 8601 UTC timezone Other Date Formats
US format: ^\d{1,2}/\d{1,2}/\d{4}$ (MM/DD/YYYY). European: ^\d{1,2}\.\d{1,2}\.\d{4}$ (DD.MM.YYYY). Time 12h: ^\d{1,2}:\d{2}(:\d{2})?\s?(AM|PM)$ (case-insensitive). Time 24h: ^([01]\d|2[0-3]):[0-5]\d$ (HH:MM). Duration: ^P\d+Y\d+M\d+DT\d+H\d+M\d+S$ (ISO 8601 duration). Always parse to a Date object for comparison and arithmetic. Be explicit about timezone to avoid off-by-one errors. Store in UTC, display in local time.
- US
- MM/DD/YYYY
- European
- DD.MM.YYYY
- 24h
- HH:MM
month first day first 00-23 hours