I have a loop for pulling data from DB, it's pretty complex however I've setup a sample code. The idea of this code is that it goes from X hour to Y hour, however with the EDT switch happening this Sunday at 2AM, the loop does not continue correctly.
I ofcourse could add a else/if however is there a proper solution for this?
Sample code:
$date = new DateTime('2016-11-05 22:00:00', new DateTimeZone('America/New_York'));
foreach(range(1,48) as $i) {
echo $date->format('Y/m/d H:i')."<br/>";
$date->add(new DateInterval('PT15M'));
}
Example output:
2016/11/05 22:00
2016/11/05 22:15
2016/11/05 22:30
2016/11/05 22:45
2016/11/05 23:00
2016/11/05 23:15
2016/11/05 23:30
2016/11/05 23:45
2016/11/06 00:00
2016/11/06 00:15
2016/11/06 00:30
2016/11/06 00:45
2016/11/06 01:00
2016/11/06 01:15
2016/11/06 01:30
2016/11/06 01:45
2016/11/06 01:00
2016/11/06 01:15
2016/11/06 01:30
2016/11/06 01:45
2016/11/06 01:00
2016/11/06 01:15
2016/11/06 01:30
2016/11/06 01:45
2016/11/06 01:00
2016/11/06 01:15
2016/11/06 01:30
2016/11/06 01:45
2016/11/06 01:00
2016/11/06 01:15
2016/11/06 01:30
2016/11/06 01:45
2016/11/06 01:00
2016/11/06 01:15
...
This loop carries on until foreach is finished, where it keeps resetting to 1AM at 2AM, is there a different way to increase the timestamp via DateTime? Any help would be appreciated