src/ICal/ICal.php
protected function parseDuration($date, $duration, $format = self::UNIX_FORMAT)
    {
        $dateTime = date_create($date);
        $dateTime->modify($duration->y . ' year');
        $dateTime->modify($duration->m . ' month');
        $dateTime->modify($duration->d . ' day');
        $dateTime->modify($duration->h . ' hour');
        $dateTime->modify($duration->i . ' minute');
        $dateTime->modify($duration->s . ' second');

        if (is_null($format)) {
            $output = $dateTime;
        } else {
            if ($format === self::UNIX_FORMAT) {
                $output = $dateTime->getTimestamp();
            } else {
                $output = $dateTime->format($format);
            }
        }

        return $output;
    }
protected function parseDuration($date, $duration, $format = self::UNIX_FORMAT)
    {
        $dateTime = date_create($date);
        $dateTime->modify($duration->y . ' year');
        $dateTime->modify($duration->m . ' month');
        $dateTime->modify($duration->d . ' day');
        $dateTime->modify($duration->h . ' hour');
        $dateTime->modify($duration->i . ' minute');
        $dateTime->modify($duration->s . ' second');

        if (is_null($format)) {
            $output = $dateTime;
        } else {
            if ($format === self::UNIX_FORMAT) {
                $output = $dateTime->getTimestamp();
            } else {
                $output = $dateTime->format($format);
            }
        }

        return $output;
    }
protected function parseDuration ( $ date , $ duration , $ format = self :: UNIX_FORMAT ) { $ dateTime = date_create ( $ date ) ; $ dateTime -> modify ( $ duration -> y . ' year' ) ; $ dateTime -> modify ( $ duration -> m . ' month' ) ; $ dateTime -> modify ( $ duration -> d . ' day' ) ; $ dateTime -> modify ( $ duration -> h . ' hour' ) ; $ dateTime -> modify ( $ duration -> i . ' minute' ) ; $ dateTime -> modify ( $ duration -> s . ' second' ) ; if ( is_null ( $ format ) ) { $ output = $ dateTime ; } else { if ( $ format === self :: UNIX_FORMAT ) { $ output = $ dateTime -> getTimestamp ( ) ; } else { $ output = $ dateTime -> format ( $ format ) ; } } return $ output ; }
Parses a duration and applies it to a date

@param  string $date
@param  string $duration
@param  string $format
@return integer|\DateTime
Parses a duration and applies it to a date