<?php
$interval = new DateInterval('PT1H');
// DST change in Europe is on the 30. October 2016
$dateTimeStart = new DateTimeImmutable('2016-10-30 01:30:00', new DateTimezone('Europe/Berlin'));
$dateTimeEnd = new DateTimeImmutable('2016-10-30 03:31:00', new DateTimezone('Europe/Berlin'));
$period = new DatePeriod($dateTimeStart, $interval, $dateTimeEnd);
foreach ($period as $date) {
echo $date->format('c') . "\n";
}
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
2016-10-30T01:30:00+02:00
2016-10-30T02:30:00+02:00
2016-10-30T03:30:00+01:00
Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments.' in /in/2aDp3:8
Stack trace:
#0 /in/2aDp3(8): DatePeriod->__construct(Object(DateTimeImmutable), Object(DateInterval), Object(DateTimeImmutable))
#1 {main}
thrown in /in/2aDp3 on line 8
Process exited with code 255.