---
title: "CMSyncConvertTime(_:from:to:)"
framework: coremedia
role: symbol
role_heading: Function
path: "coremedia/cmsyncconverttime(_:from:to:)"
---

# CMSyncConvertTime(_:from:to:)

Converts a time from one timebase or clock to another timebase or clock.

## Declaration

```swift
func CMSyncConvertTime(_ time: CMTime, from fromClockOrTimebase: CMClockOrTimebase, to toClockOrTimebase: CMClockOrTimebase) -> CMTime
```

## Discussion

Discussion If both have a common host, the function syncs the clock or timebase based on the rates in the common tree rooted in that host. If they have different host clocks (or are both clocks), this calculation also compensates for measured drift between the clocks. To convert to or from host time, pass CMClockGetHostTimeClock() as the appropriate argument.

## See Also

### Getting and Syncing Time

- [CMSyncGetTime(_:)](coremedia/cmsyncgettime(_:).md)
- [CMSyncGetRelativeRate(_:relativeTo:)](coremedia/cmsyncgetrelativerate(_:relativeto:).md)
- [CMSyncGetRelativeRateAndAnchorTime(_:relativeTo:relativeRateOut:anchorTimeOut:relativeToAnchorTimeOut:)](coremedia/cmsyncgetrelativerateandanchortime(_:relativeto:relativerateout:anchortimeout:relativetoanchortimeout:).md)
