<?php
$start = new DateTimeImmutable('2012-07-01');
$end = new DateTimeImmutable('2012-07-31');
$interval = new DateInterval('P7D');
$recurrences = 4;
$periodWithRecurrences = new DatePeriod($start, $interval, $recurrences);
echo "With recurrences:\n";
foreach ($periodWithRecurrences as $r) {
printf("start=%s\n", $periodWithRecurrences->start->format("Y-m-d H:i:s"));
printf("current=%s\n", $periodWithRecurrences->current->format("Y-m-d H:i:s"));
printf("end=%s\n", $periodWithRecurrences->end ? $periodWithRecurrences->end->format("Y-m-d H:i:s") : "null");
printf("interval=%s\n", $periodWithRecurrences->interval->format("P%r%yY%mM%dDT%hH%iM%sS (%ad)"));
printf("recurrences=%s\n", $periodWithRecurrences->recurrences);
printf("include_start_date=%s\n", $periodWithRecurrences->include_start_date);
break;
}
$periodWithoutRecurrences = new DatePeriod($start, $interval, $end);
echo "\nWithout recurrences:\n";
foreach ($periodWithoutRecurrences as $r) {
printf("start=%s\n", $periodWithoutRecurrences->start->format("Y-m-d H:i:s"));
printf("current=%s\n", $periodWithoutRecurrences->current->format("Y-m-d H:i:s"));
printf("end=%s\n", $periodWithoutRecurrences->end ? $periodWithoutRecurrences->end->format("Y-m-d H:i:s") : "null");
printf("interval=%s\n", $periodWithoutRecurrences->interval->format("P%r%yY%mM%dDT%hH%iM%sS (%ad)"));
printf("recurrences=%s\n", $periodWithoutRecurrences->recurrences);
printf("include_start_date=%s\n", $periodWithoutRecurrences->include_start_date);
break;
}
preferences:
53.8 ms | 402 KiB | 5 Q