---
title: "CMTimeCompare(_:_:)"
framework: coremedia
role: symbol
role_heading: Function
path: "coremedia/cmtimecompare(_:_:)"
---

# CMTimeCompare(_:_:)

Returns the numerical relationship of two times.

## Declaration

```swift
func CMTimeCompare(_ time1: CMTime, _ time2: CMTime) -> Int32
```

## Parameters

- `time1`: A time to compare.
- `time2`: Another time to compare.

## Return Value

Return Value A numeric value that indicates the relative order of the times.

## Discussion

Discussion This method returns the following values depending on the relationship of the time values: If time1 is less than time2, it returns -1. If time1 is greater than time2, it returns 1. If time1 and time2 are equal, it returns 0. To sort numeric and nonnumeric times consistently, this call uses the following sort rules: -infinity < all finite values < indefinite < +infinity < invalid Times with numerically larger epochs are greater than those with smaller epochs. `` tip: You can also use the CMTIME_COMPARE_INLINE macro to compare times. This macro results in a more readable expression because it puts the comparison operator between the operands.

## See Also

### Comparing Times

- [CMTimeMaximum(_:_:)](coremedia/cmtimemaximum(_:_:).md)
- [CMTimeMinimum(_:_:)](coremedia/cmtimeminimum(_:_:).md)
