---
title: timeDuration
framework: foundation
role: symbol
role_heading: Type Property
path: foundation/formatstyle/timeduration
---

# timeDuration

A style for formatting a duration expressed as a range of dates.

## Declaration

```swift
static var timeDuration: Date.ComponentsFormatStyle { get }
```

## Discussion

Discussion Use this type property when the call point allows the use of Date.FormatStyle. You typically do this when calling the formatted(_:) method of Date. The following example creates a one hour, thirty-five minute range between two dates, then uses SELF to format this duration as a string. let now = Date.now let future = now.addingTimeInterval(95) let dateRange = now..<future let formatted = dateRange.formatted(.timeDuration) // "1:35" XCTAssertEqual(formatted, "1:35") To use the Swift Duration type rather than Date, use Duration.TimeFormatStyle or Duration.UnitsFormatStyle instead, and their corresponding static accessors, time(pattern:) and units(allowed:width:maximumUnitCount:zeroValueUnits:valueLength:fractionalPart:).

## See Also

### Applying duration styles

- [Date.ComponentsFormatStyle](foundation/date/componentsformatstyle.md)
- [time(pattern:)](foundation/formatstyle/time(pattern:).md)
- [units(allowed:width:maximumUnitCount:zeroValueUnits:valueLength:fractionalPart:)](foundation/formatstyle/units(allowed:width:maximumunitcount:zerovalueunits:valuelength:fractionalpart:).md)
- [units(allowed:width:maximumUnitCount:zeroValueUnits:valueLengthLimits:fractionalPart:)](foundation/formatstyle/units(allowed:width:maximumunitcount:zerovalueunits:valuelengthlimits:fractionalpart:).md)
