- Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- 2019-11-03T00:00:00-05:00 2019-11-03T00:00:00-05:00
<?php
$tz = new DateTimeZone('America/Chicago'); // A timezone that has DST
$five_hours_interval = new DateInterval('PT5H');
$date = new DateTime("2019-11-03 00:00:00", $tz); // goes backward at 2am
echo $date->format('c') . "\n";
// Add five hours and subtract 5 hours. The $newDate should then equal the date.
$five_hours_later = $date->add($five_hours_interval);
$newDate = $five_hours_later->sub($five_hours_interval);
echo $newDate->format('c');