isIso8601Interval.php
Table of Contents
Functions
- isIso8601Interval() : bool
- Validates whether a string is a valid ISO 8601 time interval.
Functions
isIso8601Interval()
Validates whether a string is a valid ISO 8601 time interval.
isIso8601Interval(string $value) : bool
An interval is two ISO 8601 expressions joined by a / separator, in one of
the following forms:
<start>/<end>— two strict date-times (e.g.2026-05-14T00:00:00Z/2026-05-15T00:00:00Z)<start>/<duration>— a start date-time and a duration (e.g.2026-05-14T00:00:00Z/P1D)<duration>/<end>— a duration and an end date-time (e.g.P1D/2026-05-15T00:00:00Z)
The single-<duration> short form (e.g. P1D alone) is intentionally
rejected: use Iso8601Duration for that case. Open intervals
(--/<end> and <start>/-- from ISO 8601:2019) are also rejected for now.
Date-time components are validated in strict mode (mandatory T separator).
Parameters
- $value : string
-
The interval string to validate
Tags
Return values
bool —True if the string is a valid ISO 8601 interval, false otherwise