src/Interval.php
/**
	 * Returns an int representing the interval in seconds
	 * 
	 * @throws RuntimeException if the interval has non-zero years or months, as these are ambiguous
	 *
	 * @param DateInterval $interval
	 * 
	 * @return int
	 */
Returns an int representing the interval in seconds

@throws RuntimeException if the interval has non-zero years or months, as these are ambiguous



@return int
Returns an int representing the interval in seconds @throws RuntimeException if the interval has non - zero years or months as these are ambiguous @return int
public static function toSeconds(DateInterval $interval): int
	{
		if ($interval->days !== false) {
			$sec = $interval->days * self::SECONDS_PER_DAY;
		} else {
			if ($interval->y || $interval->m) {
				throw new RuntimeException("Cannot get interval in seconds: years and months are ambiguous");
			}
			$sec = $interval->d * self::SECONDS_PER_DAY;
		}
		$sec += ($interval->h * self::SECONDS_PER_HOUR)
			+ ($interval->i * self::SECONDS_PER_MINUTE)
			+ $interval->s;
		return $sec;
	}
public static function toSeconds ( DateInterval $ interval ) : int { if ( $ interval -> days !== false ) { $ sec = $ interval -> days * self :: SECONDS_PER_DAY ; } else { if ( $ interval -> y || $ interval -> m ) { throw new RuntimeException ( " Cannot get interval in seconds: years and months are ambiguous " ) ; } $ sec = $ interval -> d * self :: SECONDS_PER_DAY ; } $ sec += ( $ interval -> h * self :: SECONDS_PER_HOUR ) + ( $ interval -> i * self :: SECONDS_PER_MINUTE ) + $ interval -> s ; return $ sec ; }
Returns an int representing the interval in seconds
Returns an int representing the interval in seconds
// use days when available