Ouzo\Utilities\Date::addInterval PHP Метод

addInterval() публичный статический Метод

Adds interval to current time and returns a formatted date.
public static addInterval ( string $interval, string $format = self::DEFAULT_TIME_FORMAT ) : string
$interval string
$format string
Результат string
    public static function addInterval($interval, $format = self::DEFAULT_TIME_FORMAT)
    {
        $date = Clock::now()->toDateTime();
        $date->add(new DateInterval($interval));
        return $date->format($format);
    }

Usage Example

Пример #1
0
 /**
  * @test
  */
 public function shouldAddIntervalToCurrentDate()
 {
     //when
     $date = Date::addInterval('P2Y');
     //then
     $this->assertGreaterThan(Clock::nowAsString(), $date);
 }