public function modifyTime(int $hours, int $minutes = 0, int $seconds = 0, int $microseconds = 0) : Time
    {
        if ($this->frozen) {
            throw new \RuntimeException(get_class($this) . ' is read-only, frozen.');
        }

        $modifiers = [];
        if ($hours) {
            $modifiers[] = ($hours > 0 ? '+' : '-') . abs($hours) . ' ' . (abs($hours) > 1 ? 'hours' : 'hour');
        }
        if ($minutes) {
            $modifiers[] = ($minutes > 0 ? '+' : '-') . abs($minutes) . ' ' . (abs($minutes) > 1 ? 'minutes' : 'minute');
        }
        if ($seconds) {
            $modifiers[] = ($seconds > 0 ? '+' : '-') . abs($seconds) . ' ' . (abs($seconds) > 1 ? 'seconds' : 'second');
        }
        if ($microseconds && (PHP_MAJOR_VERSION != 7 || PHP_MINOR_VERSION)) {
            $modifiers[] = ($microseconds > 0 ? '+' : '-') . abs($microseconds)
                . ' ' . (abs($microseconds) > 1 ? 'microseconds' : 'microsecond');
        }
        if ($modifiers) {
            $this->modify(join(' ', $modifiers));
        }
        return $this;
    }
public function modifyTime(int $hours, int $minutes = 0, int $seconds = 0, int $microseconds = 0) : Time
    {
        if ($this->frozen) {
            throw new \RuntimeException(get_class($this) . ' is read-only, frozen.');
        }

        $modifiers = [];
        if ($hours) {
            $modifiers[] = ($hours > 0 ? '+' : '-') . abs($hours) . ' ' . (abs($hours) > 1 ? 'hours' : 'hour');
        }
        if ($minutes) {
            $modifiers[] = ($minutes > 0 ? '+' : '-') . abs($minutes) . ' ' . (abs($minutes) > 1 ? 'minutes' : 'minute');
        }
        if ($seconds) {
            $modifiers[] = ($seconds > 0 ? '+' : '-') . abs($seconds) . ' ' . (abs($seconds) > 1 ? 'seconds' : 'second');
        }
        if ($microseconds && (PHP_MAJOR_VERSION != 7 || PHP_MINOR_VERSION)) {
            $modifiers[] = ($microseconds > 0 ? '+' : '-') . abs($microseconds)
                . ' ' . (abs($microseconds) > 1 ? 'microseconds' : 'microsecond');
        }
        if ($modifiers) {
            $this->modify(join(' ', $modifiers));
        }
        return $this;
    }
public function modifyTime ( int $ hours , int $ minutes = 0 , int $ seconds = 0 , int $ microseconds = 0 ) : Time { if ( $ this -> frozen ) { throw new \ RuntimeException ( get_class ( $ this ) . ' is read-only, frozen.' ) ; } $ modifiers = [ ] ; if ( $ hours ) { $ modifiers [ ] = ( $ hours > 0 ? '+' : '-' ) . abs ( $ hours ) . ' ' . ( abs ( $ hours ) > 1 ? 'hours' : 'hour' ) ; } if ( $ minutes ) { $ modifiers [ ] = ( $ minutes > 0 ? '+' : '-' ) . abs ( $ minutes ) . ' ' . ( abs ( $ minutes ) > 1 ? 'minutes' : 'minute' ) ; } if ( $ seconds ) { $ modifiers [ ] = ( $ seconds > 0 ? '+' : '-' ) . abs ( $ seconds ) . ' ' . ( abs ( $ seconds ) > 1 ? 'seconds' : 'second' ) ; } if ( $ microseconds && ( PHP_MAJOR_VERSION != 7 || PHP_MINOR_VERSION ) ) { $ modifiers [ ] = ( $ microseconds > 0 ? '+' : '-' ) . abs ( $ microseconds ) . ' ' . ( abs ( $ microseconds ) > 1 ? 'microseconds' : 'microsecond' ) ; } if ( $ modifiers ) { $ this -> modify ( join ( ' ' , $ modifiers ) ) ; } return $ this ; }
Add to or subtract from one or more time parts.

Native \DateTime::modify():
- is difficult to use and it's format argument isn't documented
- doesn't throw exception on failure

@param int $hours
Subtracts if negative.
@param int $minutes
Subtracts if negative.
@param int $seconds
Subtracts if negative.
@param int $microseconds
Subtracts if negative.
Ignored when PHP 7.0 (<7.1).

@return $this|Time

@throws \RuntimeException
Frozen.
Add to or subtract from one or more time parts .