Created
May 23, 2016 05:30
-
-
Save heiglandreas/7b7fc82471f4619f66f329a31b566112 to your computer and use it in GitHub Desktop.
DST-Issues in PHPs Date-Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2016-10-30T01:30:00+02:00 | |
2016-10-30T02:30:00+02:00 | |
2016-10-30T02:30:00+01:00 | |
2016-10-30T03:30:00+01:00 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
} | |
// See the result at https://3v4l.org/2aDp3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment