-
Notifications
You must be signed in to change notification settings - Fork 2
DateRange
Viames Marino edited this page Feb 23, 2026
·
1 revision
Pair\Helpers\DateRange is an immutable value object for date-time intervals.
contains(DateTimeInterface $dt): booloverlaps(DateRange $other): boolintersection(DateRange $other): ?DateRangeexpand(?DateInterval $before = null, ?DateInterval $after = null): DateRange-
shift(DateInterval $delta): DateRange,shiftBy(string $modifier): DateRange forMonth(), previousMonth(), nextMonth()toArray(string $format = 'Y-m-d H:i:s'): array-
toSqlParams(...): array,toSqlWhere(string $column, ...): string toPeriod(DateInterval $step, int $options = 0): DatePeriod
$range = new \Pair\Helpers\DateRange(
new DateTimeImmutable('2026-02-01 00:00:00'),
new DateTimeImmutable('2026-02-29 23:59:59')
);
$where = $range->toSqlWhere('createdAt');
$params = $range->toSqlParams(':start', ':end');
$orders = \Pair\Core\Query::table('orders')
->whereRaw($where, $params)
->get();- Constructor validates
start <= end. - Supports month helpers and localization-aware formatting methods.
See also: Query, QueryFilter.