Are there alternative methods in PHP, besides DateTime::modify, that can be used to increment time values in a loop more effectively?

When incrementing time values in a loop, using DateTime::modify can be effective but may not be the most efficient method. An alternative approach is to use DateTimeImmutable objects and create new instances with the updated time values in each iteration of the loop. This can avoid potential issues with modifying the same DateTime object repeatedly.

// Using DateTimeImmutable objects to increment time values in a loop
$startTime = new DateTimeImmutable('2022-01-01 00:00:00');
$endTime = new DateTimeImmutable('2022-01-01 12:00:00');
$interval = new DateInterval('PT1H');

$currentTime = $startTime;
while ($currentTime < $endTime) {
    echo $currentTime->format('Y-m-d H:i:s') . "\n";
    
    $currentTime = $currentTime->add($interval);
}