Negative DateInterval

前端 未结 7 2315
后悔当初
后悔当初 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:31

    You can used sub http://php.net/manual/en/datetime.sub.php

    Here is example

    $startDate = new \DateTime('2018-01-08 13:54:06');
    $startDate->sub(new \DateInterval('P1D'));
    

提交回复
热议问题