I want to create a DatePeriod object with a negative DateInterval.
This creates a DatePeriod with the year increasing from today to 2016.
$this->S
This took a little digging. The only way I was able to get a negative DateInterval
was by doing this:
$interval = DateInterval::createFromDateString('-1 day');
However, there is a catch. DatePeriod
seems to not work for negative intervals. If you set the start date to be before the end date then it doesn't contain any dates at all and if you flip so that the start date is after the end date then it looks backwards indefinitely.
You're probably going to have to restructure your code to loop through the dates using DateTime::sub
with a positive DateInterval
or DateTime::add
with the negative one.