Skip to content

Instantly share code, notes, and snippets.

@heiglandreas
Created May 23, 2016 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heiglandreas/7b7fc82471f4619f66f329a31b566112 to your computer and use it in GitHub Desktop.
Save heiglandreas/7b7fc82471f4619f66f329a31b566112 to your computer and use it in GitHub Desktop.
DST-Issues in PHPs Date-Component
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
<?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