Negative DateInterval

前端 未结 7 2240
后悔当初
后悔当初 2020-12-17 09:59

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         


        
7条回答
  •  [愿得一人]
    2020-12-17 10:29

    This extract worked for me:

        $iDate = $endDate;
        while($iDate >= $startDate) {
            $dates[] = new DateTime($iDate->format('Y-m-d'));
            $iDate->sub(new DateInterval("P1D"));
        }
    

提交回复
热议问题