I want to create a DatePeriod object with a negative DateInterval.
This creates a DatePeriod with the year increasing from today to 2016.
$this->Set('dates', new DatePeriod(new DateTime(), new DateInterval('P1Y'), new DateTime('2016-06-06')));
I want to start at 2016, and using a negative DateInterval move towards todays year
Something like this might illustrate my desire
$this->Set('dates', new DatePeriod(new DateTime('2016-06-06'), new DateInterval('-P1Y'), new DateTime()));
I just can't find any extended info on either DatePeriod or DateInterval on how to do this. All i find is that DateInterval can be inverted.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…